//
//  HWLoginController.m
//  HWanGame
//
//  Created by 陈道斌 on 2019/9/11.
//  Copyright © 2019 Chendaobin. All rights reserved.
//

#import "HWLoginController.h"
#import "HWAccountRegisteredViewController.h"
#import  "HWPhoneRegisteredController.h"
#import "HWTouristsView.h"
#import "HWVerificationViewController.h"
#import "HWForgotPasswordViewController.h" // 忘记密码
#import "WXApi.h"

#import <TencentOpenAPI/TencentOAuth.h>

// #import <CL_ShanYanSDK/CL_ShanYanSDK.h>

//引入JVERIFICATIONService.h头文件
#import "JVERIFICATIONService.h"
// 如果需要使用 idfa 功能所需要引入的头文件（可选）
#import <AdSupport/AdSupport.h>
#import "HWWebViewGameViewController.h"

#import "HWPhoneNumberLoginController.h"  // 手机号登录
#import "HWSetcodeAndPasswordViewController.h"




@interface HWLoginController ()<HWTouristsViewDelegate,WXApiDelegate,TencentSessionDelegate,UITextViewDelegate>
{
    
    NSString *member_id; //推广id
    NSString *_code;
    
}
@property(strong,nonatomic) UIView *loginView;
@property(strong,nonatomic) UIImageView *icoImageView;
@property(strong,nonatomic) UITextField *accounttextField; // 账号
@property(strong,nonatomic) UITextField *miaTexfeild;
@property(strong,nonatomic) HWTouristsView *touristsView;
@property(strong,nonatomic) NSString *jizhuStr; // 是否选中账号

@property(strong,nonatomic)UIButton *weixingBut; // 微信登录
@property(strong,nonatomic)UIButton *QQBut;  // QQ登录

@property(nonatomic, strong) TencentOAuth * tencentOAuth;
@property(nonatomic,strong) UIButton *loginBut;
@property(strong,nonatomic) UIView *logiviewOrweixingView;
@property(copy,nonatomic) NSString *dataStr; // 存储
@property(copy,nonatomic) NSString *QQaccessTokenStr;
@property(copy,nonatomic) NSString *weixingaccessTokenStr;




@end

@implementation HWLoginController

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    
    [self.navigationController setNavigationBarHidden:YES ];
}

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    [self.navigationController setNavigationBarHidden:NO];
    
    // [self.navigationController setNavigationBarHidden:NO animated:animated];
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    
    
    [self.view endEditing:YES];
    
}


- (void)viewDidLoad {
    [super viewDidLoad];
    
    //    [self setupUI];
    //    // shezhi
    //    [self navigaView];
    
    
    
    //预取号
    //    [CLShanYanSDKManager preGetPhonenumber:^(CLCompleteResult * _Nonnull completeResult) {
    //
    //
    //     //    [self quickLoginBtnClick:nil];
    //        [NSThread currentThread];
    ////         dispatch_async(dispatch_get_main_queue(), ^{
    ////              [self quickLoginBtnClick];
    ////        });
    //      //    [self quickLoginBtnClick];
    //       //  [self performSelector:@selector(quickLoginBtnClick) withObject:nil afterDelay:2];
    //
    //    }];
    
    
    
    [self setupUI];
    // shezhi
    [self navigaView];
    
    
    
    
    
    //       [self performSelector:@selector(quickLoginBtnClick) withObject:nil afterDelay:2];
    
    // 手机网游  BT游戏  折扣游戏  H5游戏
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(wxLogin:) name:@"wxLogin" object:nil];
    
    //先判断之前是否登录过
    //   [self authAccessToken];
    
    
    [self chaxunshipingyijiandenglu];
    
    if ([self.shifouJiaruStr isEqualToString:@"1"]) {
        //  [self customWindowUI];
    } else {
        [self customWindowUI];
        
    }
    //    [self customWindowUI];
    
    //添加一些登录控件 微信 QQ 手机号登录  用户注册
    [self addlogingkongjiangView];
    
    //  [self linghsiButredView];
    
}


//
- (void)linghsiButredView {
    
    UIButton *button1 = [UIButton buttonWithType:UIButtonTypeCustom];
    button1.frame = CGRectMake(30, 30, 100, 100);
    button1.backgroundColor = [UIColor redColor];
    [button1 addTarget:self action:@selector(shezhizhanghaomima) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button1];
    
    
}

///
- (void)shezhizhanghaomima {
    
    
    //  [self.navigationController popViewControllerAnimated:NO];
    
    HWSetcodeAndPasswordViewController *phone =  [[HWSetcodeAndPasswordViewController alloc]init];
    phone.dataStr = self.dataStr;
    
    [[[HWViewUtils  getCurrentVC] navigationController]  pushViewController:phone animated:NO];
    
    
    
    
}



//添加一些登录控件 微信 QQ 手机号登录  用户注册
- (void)addlogingkongjiangView {
    
    
    
    
    
    
    UILabel *nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(40,kScreenH -48-CF_TabbarSafeBottomMargin-10-17-20, kScreenW-80, 17)];
    //     nameLabel.text = fanlilistArr[i];
    //  nameLabel.backgroundColor =  RGB(248, 119, 6);
    nameLabel.backgroundColor = [UIColor clearColor];
    nameLabel.textAlignment = NSTextAlignmentCenter;
    nameLabel.font = [UIFont systemFontOfSize:14];
    nameLabel.textColor = RGB(170 , 170, 170);
    //     nameLabel.layer.cornerRadius = 8;
    //     nameLabel.layer.masksToBounds = YES;
    nameLabel.text = @"如没有账号，请点击用户注册按钮注册平台账号";
    nameLabel.text = [HWjianzhiduiObject keylocalization:@"如没有账号，请点击用户注册按钮注册平台账号"];
    
    [self.view addSubview:nameLabel];
    
    
    
    
    
    
    
    
    
    
    
    
    
    self.logiviewOrweixingView = [[UIView alloc]initWithFrame:CGRectMake(0, kScreenH -48-CF_TabbarSafeBottomMargin-10, kScreenW, 48)];
    self.logiviewOrweixingView.backgroundColor = [UIColor clearColor];
    [self.view addSubview:self.logiviewOrweixingView];
    
    
    NSArray *arr1 = nil;
    NSArray *arr2 = nil;
    
    
    
    if ([[HWLocallyStoredData getLogQQAndWeichat] isEqualToString:@"1"]) {
        
        
        
        arr1 = @[@"shoujidengluhao",@"youkedengluzhuce"];
        //    arr2 = @[@"手机登录",@"用户注册"];
        arr2 = @[[HWjianzhiduiObject keylocalization:@"手机登录"],[HWjianzhiduiObject keylocalization:@"用户注册"]];
        
        //        NSArray *arr1 = @[@"shoujidengluhao",@"weixindengluico",@"QQdengluico",@"youkedengluzhuce"];
        //        NSArray *arr2 = @[@"手机登录",@"微信登录",@"QQ 登录",@"用户注册"];
        //
        
        
        
    } else {
        
        //            NSArray *arr1 = @[@"shoujidengluhao",@"youkedengluzhuce"];
        //            NSArray *arr2 = @[@"手机登录",@"用户注册"];
        
        arr1 = @[@"shoujidengluhao",@"weixindengluico",@"QQdengluico",@"youkedengluzhuce"];
        arr2 = @[@"手机登录",@"微信登录",@"QQ 登录",@"用户注册"];
        
        
    }
    
    
    
    
    
    CGFloat hengjianju = (kScreenW  - arr1.count*54)/(arr1.count+1);
    //  CGFloat  shujianju = (166-100)/3;
    
    for (int i = 0 ; i < arr1.count; i++) {
        //    int row = i/4;
        int line = i% arr1.count;
        
        
        UIView *beijingview = [[UIView alloc]initWithFrame:CGRectMake(line*54+hengjianju*i+hengjianju, 0, 50+4, 48)];
        beijingview.backgroundColor = [UIColor clearColor];
        [self.logiviewOrweixingView addSubview:beijingview];
        
        beijingview.tag = i;
        UITapGestureRecognizer *beijingGesture = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(denglubeijingTap:)];
        [beijingview addGestureRecognizer:beijingGesture];
        
        
        UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake((54-24)/2, 0, 24, 24)];
        // imageView.image = [UIImage imageNamed:self.icoArr[i]];
        //   imageView.userInteractionEnabled = YES;
        imageView.image =  [UIImage imageNamed:arr1[i]];
        [beijingview addSubview:imageView];
        imageView.tag = i;
        //  [self.imageViewMuArr addObject:imageView];
        
        
        //         UITapGestureRecognizer *tap  = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(iamgetap:)];
        //         [imageView addGestureRecognizer:tap];
        
        
        
        UILabel *shulianlabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 30, 54, 20)];
        shulianlabel.textColor =RGB(68, 68, 68);
        //  shulianlabel.text = self.listArr[i];
        //  shulianlabel.backgroundColor = [UIColor orangeColor];
        shulianlabel.font = [UIFont systemFontOfSize:12];
        shulianlabel.textAlignment = NSTextAlignmentCenter;
        shulianlabel.text = arr2[i];
        
        [beijingview addSubview:shulianlabel];
        //    [self.labeMuArr addObject:shulianlabel];
        
        
        
        
    }
    
    
    
    
    
    
    
}

#pragma maek ---------
- (void)denglubeijingTap:(UITapGestureRecognizer *)sender {
    
    
    UIView *view = sender.view;
    NSInteger tag = view.tag;
    NSLog(@"%d",tag);
    
    
    if ([[HWLocallyStoredData getLogQQAndWeichat] isEqualToString:@"1"]) {
        
        if (tag == 0 ) {
            
            [self.navigationController popViewControllerAnimated:NO];
            if (self.goBack) {
                self.goBack();
            }
            HWPhoneNumberLoginController *phone =  [[HWPhoneNumberLoginController alloc]init];
            [[[HWViewUtils  getCurrentVC] navigationController]  pushViewController:phone animated:NO];
            
            
            
        }else if (tag == 1) {
            
            [self.navigationController popViewControllerAnimated:NO];
            if (self.goBack) {
                self.goBack();
            }
            HWAccountRegisteredViewController *requ = [[HWAccountRegisteredViewController alloc]init];
            [[[HWViewUtils  getCurrentVC] navigationController]  pushViewController:requ animated:NO];
            
            
            
            
        }
        
        
        
        
        
        
        
        
    } else {
        
        
        if (tag == 0 ) {
            
            
            
            [self.navigationController popViewControllerAnimated:NO];
            
            if (self.goBack) {
                self.goBack();
            }
            HWPhoneNumberLoginController *phone =  [[HWPhoneNumberLoginController alloc]init];
            [[[HWViewUtils  getCurrentVC] navigationController]  pushViewController:phone animated:NO];
            
            
            
        } else if (tag == 1) {
            
            [self login];
            
            
        }  else if (tag == 2) {
            
            [self QQlogin];
            
            
            
        } else {
            
            
            [self.navigationController popViewControllerAnimated:NO];
            HWAccountRegisteredViewController *requ = [[HWAccountRegisteredViewController alloc]init];
            [[[HWViewUtils  getCurrentVC] navigationController]  pushViewController:requ animated:NO];
            if (self.goBack) {
                //                if (self.goBack) {
                self.goBack();
                //            }
            }
            
            
        }
        
        
        
    }
    
    
    
    
    
    
    
    
    
    
    
    
}








- (void)customWindowUI  {
    
    JVUIConfig *config = [[JVUIConfig alloc] init];
    config.navCustom = NO;
    //    config.prefersStatusBarHidden = YES;
    config.shouldAutorotate = YES;
    config.autoLayout = YES;
    //    config.orientation =  UIInterfaceOrientationPortrait;
    
    config.navReturnHidden = NO;
    config.privacyTextFontSize = 12;
    config.navText = [[NSAttributedString alloc]initWithString:@"登录统一认证" attributes:@{NSForegroundColorAttributeName:[UIColor whiteColor], NSFontAttributeName:[UIFont systemFontOfSize:18]}];
    //    config.navColor = [UIColor redColor];
    //    config.navBarBackGroundImage = [UIImage imageNamed:@"cmccLogo"];
    config.privacyTextAlignment = NSTextAlignmentLeft;
    //    config.numberFont = [UIFont systemFontOfSize:10];
    //    config.logBtnFont = [UIFont systemFontOfSize:5];
    //    config.privacyShowBookSymbol = YES;
    //    config.privacyLineSpacing = 5;
    //    config.agreementNavBackgroundColor = [UIColor redColor];
    //    config.sloganFont = [UIFont systemFontOfSize:30];
    //    config.checkViewHidden = YES;
    config.navColor = UIColor.systemBlueColor;
    config.agreementNavBackgroundColor = UIColor.systemBlueColor;
    config.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
    
    /*
     config.customLoadingViewBlock = ^(UIView *View) {
     
     //https://github.com/jdg/MBProgressHUD
     MBProgressHUD *hub = [MBProgressHUD showHUDAddedTo:View animated:YES];
     hub.backgroundColor = [UIColor clearColor];
     hub.label.text = @"正在登录..";
     [hub showAnimated:YES];
     };
     */
    
    /*
     config.customPrivacyAlertViewBlock = ^(UIViewController *vc) {
     UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"请点击同意协议" message:nil preferredStyle:UIAlertControllerStyleAlert];
     [alert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:nil]];
     [vc presentViewController:alert animated:true completion:nil];
     };
     */
    
    
    //logo
    config.logoImg = [UIImage imageNamed:@"cmccLogo"];
    CGFloat logoWidth = config.logoImg.size.width?:100;
    CGFloat logoHeight = logoWidth;
    JVLayoutConstraint *logoConstraintX = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterX multiplier:1 constant:0];
    JVLayoutConstraint *logoConstraintY = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterY multiplier:1 constant:-90];
    JVLayoutConstraint *logoConstraintW = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeWidth multiplier:1 constant:logoWidth];
    JVLayoutConstraint *logoConstraintH = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeHeight multiplier:1 constant:logoHeight];
    config.logoConstraints = @[logoConstraintX,logoConstraintY,logoConstraintW,logoConstraintH];
    config.logoHorizontalConstraints = config.logoConstraints;
    
    
    
    //号码栏
    JVLayoutConstraint *numberConstraintX = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterX multiplier:1 constant:0];
    JVLayoutConstraint *numberConstraintY = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterY multiplier:1 constant:-55];
    JVLayoutConstraint *numberConstraintW = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeWidth multiplier:1 constant:130];
    JVLayoutConstraint *numberConstraintH = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeHeight multiplier:1 constant:25];
    config.numberConstraints = @[numberConstraintX,numberConstraintY, numberConstraintW, numberConstraintH];
    config.numberHorizontalConstraints = config.numberConstraints;
    
    //slogan展示
    JVLayoutConstraint *sloganConstraintX = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterX multiplier:1 constant:0];
    JVLayoutConstraint *sloganConstraintY = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterY multiplier:1 constant:-20];
    JVLayoutConstraint *sloganConstraintW = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeWidth multiplier:1 constant:130];
    JVLayoutConstraint *sloganConstraintH = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeHeight multiplier:1 constant:20];
    config.sloganConstraints = @[sloganConstraintX,sloganConstraintY, sloganConstraintW, sloganConstraintH];
    config.sloganHorizontalConstraints = config.sloganConstraints;
    
    
    //登录按钮
    UIImage *login_nor_image = [self imageNamed1:@"loginBtn_Nor"];
    UIImage *login_dis_image = [self imageNamed1:@"loginBtn_Dis"];
    UIImage *login_hig_image = [self imageNamed1:@"loginBtn_Hig"];
    if (login_nor_image && login_dis_image && login_hig_image) {
        config.logBtnImgs = @[login_nor_image, login_dis_image, login_hig_image];
    }
    CGFloat loginButtonWidth = login_nor_image.size.width?:100;
    CGFloat loginButtonHeight = login_nor_image.size.height?:100;
    JVLayoutConstraint *loginConstraintX = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterX multiplier:1 constant:0];
    JVLayoutConstraint *loginConstraintY = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterY multiplier:1 constant:30];
    JVLayoutConstraint *loginConstraintW = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeWidth multiplier:1 constant:loginButtonWidth];
    JVLayoutConstraint *loginConstraintH = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeHeight multiplier:1 constant:loginButtonHeight];
    config.logBtnConstraints = @[loginConstraintX,loginConstraintY,loginConstraintW,loginConstraintH];
    config.logBtnHorizontalConstraints = config.logBtnConstraints;
    
    //勾选框
    UIImage * uncheckedImg = [self imageNamed1:@"checkBox_unSelected"];
    UIImage * checkedImg = [self imageNamed1:@"checkBox_selected"];
    CGFloat checkViewWidth = uncheckedImg.size.width;
    CGFloat checkViewHeight = uncheckedImg.size.height;
    config.uncheckedImg = uncheckedImg;
    config.checkedImg = checkedImg;
    JVLayoutConstraint *checkViewConstraintX = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeLeft multiplier:1 constant:20];
    JVLayoutConstraint *checkViewConstraintY = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemPrivacy attribute:NSLayoutAttributeCenterY multiplier:1 constant:-18];
    JVLayoutConstraint *checkViewConstraintW = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeWidth multiplier:1 constant:checkViewWidth];
    JVLayoutConstraint *checkViewConstraintH = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeHeight multiplier:1 constant:checkViewHeight];
    config.checkViewConstraints = @[checkViewConstraintX,checkViewConstraintY,checkViewConstraintW,checkViewConstraintH];
    config.checkViewHorizontalConstraints = config.checkViewConstraints;
    
    
    //隐私
    CGFloat spacing = checkViewWidth + 20 + 5;
    config.privacyState = YES;
    
    JVLayoutConstraint *privacyConstraintX = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeLeft multiplier:1 constant:spacing];
    JVLayoutConstraint *privacyConstraintX2 = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeRight multiplier:1 constant:-spacing];
    JVLayoutConstraint *privacyConstraintY = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeBottom multiplier:1 constant:-10];
    JVLayoutConstraint *privacyConstraintH = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeHeight multiplier:1 constant:50];
    config.privacyConstraints = @[privacyConstraintX,privacyConstraintX2,privacyConstraintY,privacyConstraintH];
    config.privacyHorizontalConstraints = config.privacyConstraints;
    
    
    //loading
    JVLayoutConstraint *loadingConstraintX = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterX multiplier:1 constant:0];
    JVLayoutConstraint *loadingConstraintY = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterY multiplier:1 constant:0];
    JVLayoutConstraint *loadingConstraintW = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeWidth multiplier:1 constant:30];
    JVLayoutConstraint *loadingConstraintH = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeHeight multiplier:1 constant:30];
    config.loadingConstraints = @[loadingConstraintX,loadingConstraintY,loadingConstraintW,loadingConstraintH];
    config.loadingHorizontalConstraints = config.loadingConstraints;
    
    
    /*
     config.authPageBackgroundImage = [UIImage imageNamed:@"背景图"];
     config.navColor = [UIColor redColor];
     config.preferredStatusBarStyle = 0;
     config.navText = [[NSAttributedString alloc] initWithString:@"自定义标题"];
     config.navReturnImg = [UIImage imageNamed:@"自定义返回键"];
     UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
     button.frame = CGRectMake(0, 0, 44, 44);
     button.backgroundColor = [UIColor greenColor];
     config.navControl = [[UIBarButtonItem alloc] initWithCustomView:button];
     config.logoHidden = NO;
     config.logBtnText = @"自定义登录按钮文字";
     config.logBtnTextColor = [UIColor redColor];
     config.numberColor = [UIColor blueColor];
     config.appPrivacyOne = @[@"应用自定义服务条款1",@"https://www.jiguang.cn/about"];
     config.appPrivacyTwo = @[@"应用自定义服务条款2",@"https://www.jiguang.cn/about"];
     config.privacyComponents = @[@"文本1",@"文本2",@"文本3",@"文本4"];
     config.appPrivacyColor = @[[UIColor redColor], [UIColor blueColor]];
     config.sloganTextColor = [UIColor redColor];
     config.navCustom = NO;
     config.numberSize = 24;
     config.privacyState = YES;
     */
    
    
    [JVERIFICATIONService customUIWithConfig:config customViews:^(UIView *customAreaView) {
        /*
         //添加一个自定义label
         UILabel *lable  = [[UILabel alloc] init];
         lable.text = @"这是一个自定义label";
         [lable sizeToFit];
         lable.center = customAreaView.center;
         [customAreaView addSubview:lable];
         */
        
    }];
    
    
    
    
    
}




- (UIImage *)imageNamed1:(NSString *)nameStr  {
    
    
    // NSBundle *bundlePath = [[NSBundle mainBundle]pathForResource:@"JVerificationResource" ofType:@"bundle"];
    
    // UIImage   *image  = [UIImage imageWithContentsOfFile:@"%@/%@.png",bundlePath,str];
    
    
    NSString *str =[NSString stringWithFormat:@"JVerificationResource.bundle/%@",nameStr];
    
    
    UIImage   *image =  [UIImage  imageNamed:str];
    
    
    return  image;
    
    
    
}


















// 查询是否一键登录
- (void)chaxunshipingyijiandenglu {
    
    
    
    
    
    NSDictionary *parametes = @{
        @"ct" :  @"app",
        @"ios" : @"1",
        @"ac" : @"config"
        
    };
    [HWWebUtils do3GetWithParameters:parametes progress:nil success:^(id response) {
        
        
        
        
        
        
        NSString *codeStr =  [NSString stringWithFormat:@"%@",response[@"code"]];
        if ([codeStr intValue] == 1) {
            
            NSString   *onelogin  = [NSString stringWithFormat:@"%@",response[@"data"][@"onelogin"]];
            
            if ([onelogin intValue] == 1) {
                
                dispatch_async(dispatch_get_main_queue(), ^{
                    [self quickLoginBtnClick];
                });
                
            }
            
            
            
        }
        
        NSLog(@"%@",response);
        
        
        
    } failure:^(NSString *error) {
        [SVProgressHUD dismiss];
        
        
    }];
    
    
    
    
    
    
    
    
    
    
    
    
    
}






- (void)shanYanAuthPageLogin{
    NSLog(@"DKJKDK");
    //  [self quickLoginBtnClick:nil]；
}



- (void)quickLoginBtnClick {
    
    
    
    BOOL isSetupClient = [JVERIFICATIONService isSetupClient];
    if (isSetupClient) {
        //初始化完成，可以进行后续操作
        NSLog(@"ooooo");
        //   [self huqouToken];
        
    }
    
    [self huqouToken];
    
    
    
}


- (void)huqouToken {
    
    
    //     JVUIConfig *config = [[JVUIConfig alloc] init];
    //     config.navReturnImg = [UIImage imageNamed:@"fanhui"];
    //     config.autoLayout = YES;
    //
    //
    //
    //    //登录按钮
    ////       UIImage *login_nor_image = [self imageNamed:@"loginBtn_Nor"];
    ////       UIImage *login_dis_image = [self imageNamed:@"loginBtn_Dis"];
    ////       UIImage *login_hig_image = [self imageNamed:@"loginBtn_Hig"];
    //    UIImage *login_nor_image =  [UIImage imageNamed:@"xuanzhongbienin"];
    //    UIImage *login_dis_image =  [UIImage imageNamed:@"xuanzhongbienin"];
    //    UIImage *login_hig_image =  [UIImage imageNamed:@"xuanzhongbienin"];
    //
    //
    //
    //
    //   //  personal_b
    //       if (login_nor_image && login_dis_image && login_hig_image) {
    //           config.logBtnImgs = @[login_nor_image, login_dis_image, login_hig_image];
    //       }
    ////       CGFloat loginButtonWidth = login_nor_image.size.width?:100;
    ////       CGFloat loginButtonHeight = login_nor_image.size.height?:100;
    //
    //
    //    CGFloat loginButtonWidth = 200;
    //    CGFloat loginButtonHeight = 40;
    //
    //
    //       JVLayoutConstraint *loginConstraintX = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterX multiplier:1 constant:0];
    //       JVLayoutConstraint *loginConstraintY = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterY multiplier:1 constant:30];
    //       JVLayoutConstraint *loginConstraintW = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeWidth multiplier:1 constant:loginButtonWidth];
    //       JVLayoutConstraint *loginConstraintH = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeHeight multiplier:1 constant:loginButtonHeight];
    //       config.logBtnConstraints = @[loginConstraintX,loginConstraintY,loginConstraintW,loginConstraintH];
    //       config.logBtnHorizontalConstraints = config.logBtnConstraints;
    //
    //
    //
    //
    //
    ////    UIImage * uncheckedImg = [self imageNamed:@"checkBox_unSelected"];
    ////       UIImage * checkedImg = [self imageNamed:@"checkBox_selected"];
    ////
    //    UIImage * uncheckedImg = [UIImage imageNamed:@"weixuanzhon"];
    //       UIImage * checkedImg = [UIImage imageNamed:@"xuanzhong"];
    //
    //
    //       CGFloat checkViewWidth = uncheckedImg.size.width;
    //       CGFloat checkViewHeight = uncheckedImg.size.height;
    //       config.uncheckedImg = uncheckedImg;
    //       config.checkedImg = checkedImg;
    //       JVLayoutConstraint *checkViewConstraintX = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeLeft multiplier:1 constant:20];
    //       JVLayoutConstraint *checkViewConstraintY = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemPrivacy attribute:NSLayoutAttributeCenterY multiplier:1 constant:0];
    //       JVLayoutConstraint *checkViewConstraintW = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeWidth multiplier:1 constant:checkViewWidth];
    //       JVLayoutConstraint *checkViewConstraintH = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeHeight multiplier:1 constant:checkViewHeight];
    //       config.checkViewConstraints = @[checkViewConstraintX,checkViewConstraintY,checkViewConstraintW,checkViewConstraintH];
    //       config.checkViewHorizontalConstraints = config.checkViewConstraints;
    //
    //
    //       //隐私
    //       CGFloat spacing = checkViewWidth + 20 + 5;
    //       config.privacyState = YES;
    //
    //       JVLayoutConstraint *privacyConstraintX = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeLeft multiplier:1 constant:spacing];
    //       JVLayoutConstraint *privacyConstraintX2 = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeRight multiplier:1 constant:-spacing];
    //       JVLayoutConstraint *privacyConstraintY = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeBottom multiplier:1 constant:-10];
    //       JVLayoutConstraint *privacyConstraintH = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeHeight multiplier:1 constant:50];
    //       config.privacyConstraints = @[privacyConstraintX,privacyConstraintX2,privacyConstraintY,privacyConstraintH];
    //       config.privacyHorizontalConstraints = config.privacyConstraints;
    //
    //
    //       //loading
    //       JVLayoutConstraint *loadingConstraintX = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterX multiplier:1 constant:0];
    //       JVLayoutConstraint *loadingConstraintY = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterY multiplier:1 constant:0];
    //       JVLayoutConstraint *loadingConstraintW = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeWidth multiplier:1 constant:30];
    //       JVLayoutConstraint *loadingConstraintH = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeHeight multiplier:1 constant:30];
    //       config.loadingConstraints = @[loadingConstraintX,loadingConstraintY,loadingConstraintW,loadingConstraintH];
    //       config.loadingHorizontalConstraints = config.loadingConstraints;
    //
    //
    //       /*
    //       config.authPageBackgroundImage = [UIImage imageNamed:@"背景图"];
    //       config.navColor = [UIColor redColor];
    //       config.preferredStatusBarStyle = 0;
    //       config.navText = [[NSAttributedString alloc] initWithString:@"自定义标题"];
    //       config.navReturnImg = [UIImage imageNamed:@"自定义返回键"];
    //       UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    //       button.frame = CGRectMake(0, 0, 44, 44);
    //       button.backgroundColor = [UIColor greenColor];
    //       config.navControl = [[UIBarButtonItem alloc] initWithCustomView:button];
    //       config.logoHidden = NO;
    //       config.logBtnText = @"自定义登录按钮文字";
    //       config.logBtnTextColor = [UIColor redColor];
    //       config.numberColor = [UIColor blueColor];
    //       config.appPrivacyOne = @[@"应用自定义服务条款1",@"https://www.jiguang.cn/about"];
    //       config.appPrivacyTwo = @[@"应用自定义服务条款2",@"https://www.jiguang.cn/about"];
    //       config.privacyComponents = @[@"文本1",@"文本2",@"文本3",@"文本4"];
    //       config.appPrivacyColor = @[[UIColor redColor], [UIColor blueColor]];
    //       config.sloganTextColor = [UIColor redColor];
    //       config.navCustom = NO;
    //       config.numberSize = 24;
    //       config.privacyState = YES;
    //        */
    ////       [JVERIFICATIONService customUIWithConfig:config customViews:^(UIView *customAreaView) {
    ////           /*
    ////           //添加一个自定义label
    ////           UILabel *lable  = [[UILabel alloc] init];
    ////           lable.text = @"这是一个自定义label";
    ////           [lable sizeToFit];
    ////           lable.center = customAreaView.center;
    ////           [customAreaView addSubview:lable];
    ////            */
    ////
    ////       }];
    ////
    //
    //
    //
    //
    //
    //   //   JVUIConfig *config1 = [[JVUIConfig alloc] init];
    //
    //
    //
    //
    //    [JVERIFICATIONService customUIWithConfig:config];
    //
    //
    //
    //
    ////
    ////       config.customLoadingViewBlock = ^(UIView *View) {
    ////             MBProgressHUD *hub = [MBProgressHUD showHUDAddedTo:View animated:YES];
    ////                    hub.backgroundColor = [UIColor clearColor];
    ////                    hub.label.text = @"正在登录..";
    ////                    [hub showAnimated:YES];
    ////
    ////
    ////
    ////
    ////
    ////       };
    
    
    
    
    
    [JVERIFICATIONService getAuthorizationWithController:self hide:YES animated:YES timeout:5*1000 completion:^(NSDictionary *result) {
        NSLog(@"一键登录 result:%@", result);
        
        NSString *code =  [NSString stringWithFormat:@"%@",result[@"code"]];
        
        if ([code intValue] == 6000) {
            [self  oneClickToLogIn:result[@"loginToken"]];
        }
        
        
        
    } actionBlock:^(NSInteger type, NSString *content) {
        NSLog(@"一键登录 actionBlock :%ld %@", (long)type , content);
    }];
    
    
    
    
    
    //             [JVERIFICATIONService getToken:5*1000  completion:^(NSDictionary *result) {
    //                           NSLog(@"11 getToken result:%@", result);
    //
    //                           [self  oneClickToLogIn:result[@"oneClickToLogIn"]];
    //
    //
    //
    //                              //TODO:获取token后相关操作
    //                       }];
    
    
    
    //    [JVERIFICATIONService getAuthorizationWithController:self hide:YES completion:^(NSDictionary *result) {
    //        NSLog(@"一键登录 result:%@", result);
    //    }];
}





// 手机号一键登录
- (void)oneClickToLogIn: (NSString *)tokenStr {
    
    
    
    
    NSString *tStr = [NSString stringWithFormat:@"%ld",[WMUtil getTimeSp]];
    
    
    NSString *signStr = [NSString stringWithFormat:@"%@%@%@",tokenStr,tStr,@"riowreopfdwrops21qe"];
    NSString  *signStrMd5  =   [WMUtil md5HexDigest:signStr];
    DLog(@"MD5 ：%@",signStrMd5);
    
    
    
    NSDictionary *parametes = @{
        @"ios" : @"1",
        @"token":tokenStr,
        @"ct"  : @"app",
        @"ac" : @"mobile_login",
        @"t" :tStr,
        @"sign" : signStrMd5,
        @"member_id":[HWLocallyStoredData getCode],
        
    };
    
    
    [MBProgressHUD showMessage:@"正在登录"];
    
    [HWWebUtils doGetWithParameters:parametes progress:nil success:^(id response) {
        
        
        
        NSString *codeStr =  [NSString stringWithFormat:@"%@",response[@"code"]];
        if ([codeStr intValue] == 1) {
            
            NSLog(@"jjjj %@",response);
            [MBProgressHUD showSuccess:@"登录成功"];
            
            [HWLocallyStoredData setUserID:response[@"data"]];
            
            
            if ([self.jizhuStr isEqualToString:@"1"]) {
                //     [HWLocallyStoredData setAccount:user_nameStr];
                
                
                
            }
            
            [self.navigationController popViewControllerAnimated:YES];
            if (self.goBack) {
                //                if (self.goBack) {
                self.goBack();
                //            }
            }
            
            
            
            
        } else if([codeStr intValue] == 2) {
            
            [MBProgressHUD hideHUD];
            self.dataStr = [NSString stringWithFormat:@"%@",response[@"data"]];
            
            [self shezhizhanghaomima];
            
            
            
        }else {
            
            [MBProgressHUD showError:response[@"message"]];
            
            
            
        }
        
        
        
    } failure:^(NSString *error) {
        // [SVProgressHUD dismiss];
        
        [MBProgressHUD showSuccess:@"登录失败"];
        [MBProgressHUD hideHUD];
        
        
    }];
    
    
    
    
    
    
    
    
}













- (void)setupUI {
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    
    UIImageView *beijiimageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, 254*CFLScaleValue+StatusBarHeight)];
    beijiimageView.image = [UIImage imageNamed:@"login_sign_bg"];
    beijiimageView.userInteractionEnabled = YES;
    beijiimageView.hidden = YES;
    [self.view addSubview:beijiimageView];
    [self addLogview];
    
    
    
}

-(void)addLogview {
    
    self.loginView = [[UIView alloc]initWithFrame:CGRectMake(25, 68+NavBarHeight, kScreenW-50, 215)];
    self.loginView.frame = CGRectMake(50,68+NavBarHeight, kScreenW-100, 70+65+12+65+40);
    self.loginView.backgroundColor = [UIColor redColor];
    
    self.loginView.backgroundColor = [UIColor whiteColor];
    
    //    self.loginView.layer.shadowColor = [UIColor colorWithRed:26/255.0 green:113/255.0 blue:255/255.0 alpha:0.35].CGColor;
    //    self.loginView.layer.shadowOffset = CGSizeMake(0,0);
    //    self.loginView.layer.shadowOpacity = 1;
    //    self.loginView.layer.shadowRadius = 10;
    //    self.loginView.layer.cornerRadius = 6;
    //    self.loginView.layer.masksToBounds = YES;
    //    self.loginView.clipsToBounds = NO;
    [self.view addSubview:self.loginView];
    
    
    
    
    
    
    
    
    UILabel *zhanghanameLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 70, 35*CFLScaleValue+25, 17)];
    //     nameLabel.text = fanlilistArr[i];
    zhanghanameLabel.textAlignment = NSTextAlignmentLeft;
    zhanghanameLabel.font = [UIFont systemFontOfSize:13];
    zhanghanameLabel.textColor = RGB(68, 68, 68);
    zhanghanameLabel.text = @"账号";
    zhanghanameLabel.text = [HWjianzhiduiObject keylocalization:@"账号"];
    
    
    [self.loginView addSubview:zhanghanameLabel];
    
    
    
    
    
    
    UITextField *textfeild = [[UITextField alloc]initWithFrame:CGRectMake(0, zhanghanameLabel.bottom+4,self.loginView.width, 44)];
    textfeild.placeholder = @"请输入";
    textfeild.backgroundColor = RGB(245, 245, 252);
    textfeild.textColor = RGB(68, 68, 68);
    textfeild.font = [UIFont systemFontOfSize:14];
    textfeild.clearsOnBeginEditing = NO;
    textfeild.clearButtonMode = UITextFieldViewModeWhileEditing;
    
    textfeild.placeholder =  [HWjianzhiduiObject keylocalization:@"请输入"];
    
    UIButton *userNameClearButton = [textfeild valueForKey:@"_clearButton"];
    [userNameClearButton setImage:[UIImage imageNamed:@"shanchuanniu"] forState:UIControlStateNormal];
    
    
    
    //     textfeild.borderStyle =UITextBorderStyleNone;
    //    textfeild.layer.borderWidth = 1;
    //    textfeild.layer.borderColor = RGB(230, 239, 233).CGColor;
    textfeild.layer.cornerRadius = 22;
    textfeild.layer.masksToBounds = YES;
    
    
    UIView *youbinview = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 12, 44)];
    textfeild.leftView = youbinview;
    //    UIImageView *imgeView = [[UIImageView alloc]initWithFrame:CGRectMake(11, 9, 16, 16)];
    //    imgeView.image = [UIImage imageNamed:@"sign_phone"];
    //
    //    [youbinview addSubview:imgeView];
    self.accounttextField = textfeild;
    textfeild.leftViewMode = UITextFieldViewModeAlways;
    if ([[HWLocallyStoredData getAccount] isEqualToString:@""]) {
        textfeild.text = @"";
        
    } else {
        
        textfeild.text = [HWLocallyStoredData getAccount];
        
    }
    
    [self.loginView addSubview:textfeild];
    
    
    
    UILabel *mimaLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, textfeild.bottom+12, 35*CFLScaleValue+25, 17)];
    //     nameLabel.text = fanlilistArr[i];
    mimaLabel.textAlignment = NSTextAlignmentLeft;
    mimaLabel.font = [UIFont systemFontOfSize:13];
    mimaLabel.textColor = RGB(68, 68, 68);
    mimaLabel.text = @"密码";
    mimaLabel.text = [HWjianzhiduiObject keylocalization:@"密码"];
    
    
    [self.loginView addSubview:mimaLabel];
    
    
    
    
    UITextField *textfeild1 = [[UITextField alloc]initWithFrame:CGRectMake(0, mimaLabel.bottom+4,self.loginView.width , 44)];
    textfeild1.placeholder = @"请输入密码";
    textfeild1.placeholder =  [HWjianzhiduiObject keylocalization:@"请输入密码"];
    textfeild1.secureTextEntry = YES;
    textfeild1.textColor = RGB(51, 51, 51);
    textfeild1.font = [UIFont systemFontOfSize:13];
    textfeild1.borderStyle =UITextBorderStyleNone;
    textfeild1.backgroundColor = RGB(245, 245, 252);
    //    textfeild1.layer.borderWidth = 1;
    //    textfeild1.layer.borderColor = RGB(230, 239, 233).CGColor;
    textfeild1.layer.cornerRadius = 22;
    textfeild1.layer.masksToBounds = YES;
    
    
    UIView *youbinview1 = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 12, 35)];
    
    
    //    UIImageView *imgeView1 = [[UIImageView alloc]initWithFrame:CGRectMake(11, 9, 16, 16)];
    //    imgeView1.image = [UIImage imageNamed:@"sign_password"];
    //
    textfeild1.leftView = youbinview1;
    
    //    [youbinview1 addSubview:imgeView1];
    textfeild1.leftViewMode = UITextFieldViewModeAlways;
    
    UIView *righview4 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 30, 35)];
    textfeild1.rightView = righview4;
    textfeild1.rightViewMode = UITextFieldViewModeAlways;
    
    //    UIImageView *imgeView4 = [[UIImageView alloc]initWithFrame:CGRectMake(0, 9, 16, 16)];
    //    imgeView4.image = [UIImage imageNamed:@"sign_surep"];
    //    [righview4 addSubview:imgeView4];
    self.miaTexfeild = textfeild1;
    
    UIButton *xianshyanj = [UIButton buttonWithType:UIButtonTypeCustom];
    xianshyanj.frame = CGRectMake(0,9, 16, 16);
    //    [xianshyanj setBackgroundImage:[UIImage imageNamed:@"sign_surep"] forState:UIControlStateNormal];
    //     [xianshyanj setBackgroundImage:[UIImage imageNamed:@"kaijisign_surep_b"] forState:UIControlStateSelected];
    //
    
    [xianshyanj setBackgroundImage:[UIImage imageNamed:@"bizheyancang"] forState:UIControlStateNormal];
    [xianshyanj setBackgroundImage:[UIImage imageNamed:@"chakankaiyang"] forState:UIControlStateSelected];
    
    [righview4 addSubview:xianshyanj];
    
    [xianshyanj addTarget:self action:@selector(xianshyanjTap:) forControlEvents:UIControlEventTouchUpInside];
    
    [self.loginView addSubview:textfeild1];
    
    
    
    UIButton *wangjibutton = [UIButton buttonWithType:UIButtonTypeCustom];
    wangjibutton.frame = CGRectMake(self.loginView.width-62-18,self.loginView.height-42+6, 62, 30);
    [wangjibutton setTitle:@"忘记密码？" forState:UIControlStateNormal];
    [wangjibutton setTitle:[HWjianzhiduiObject keylocalization:@"忘记密码?"] forState:UIControlStateNormal];
    
    [wangjibutton setTitleColor:QCchunseshensetupian forState:UIControlStateNormal];
    wangjibutton.titleLabel.font = [UIFont systemFontOfSize:12];
    [wangjibutton addTarget:self action:@selector(wangjibuttonTap) forControlEvents:UIControlEventTouchUpInside];
    
    // wangjibutton.backgroundColor = [UIColor redColor];
    [self.loginView addSubview:wangjibutton];
    
    
    NSString *jizhu =  [HWjianzhiduiObject keylocalization:@"记住账号"];
    
    UIButton *jizhubutt  = [UIButton setButtonWithFrame:CGRectMake(17, self.loginView.height-42+6, 64, 30) Title:jizhu Image:@"weixuanzhon_bynenn" Font:12 Color:RGB(153, 153, 153) Target:self Selector:@selector(buttonTap:)];
    [jizhubutt setImage:[UIImage imageNamed:@"sign_sure"] forState:UIControlStateSelected];
    self.jizhuStr = @"0";
    [jizhubutt layoutButtonWithEdgeInsetsStyle:MKButtonEdgeInsetsStyleLeft imageTitleSpace:4];
    
    [self.loginView addSubview:jizhubutt];
    
    
    
    
    NSDictionary *dic =  [[NSBundle mainBundle] infoDictionary];
    NSString *icostr =     dic[@"CFBundleIcons"][@"CFBundlePrimaryIcon"][@"CFBundleIconName"];
    //UIImage *appIcon = [UIImage imageNamed: [[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleIcons"] objectAtIndex:0]];
    UIImage  *appIcon = [UIImage imageNamed:icostr];
    appIcon = [UIImage imageNamed:@"AppIcon"];
    
    self.icoImageView = [[UIImageView alloc]initWithFrame:CGRectMake((self.loginView.width-50)/2, 0, 50, 50)];
    //   self.icoImageView.image = [UIImage imageNamed:@"acat"];
    self.icoImageView.layer.cornerRadius = 10;
    self.icoImageView.layer.masksToBounds = YES;
    self.icoImageView.image = appIcon;
    //   self.icoImageView.layer.borderWidth = 5;
    //  self.icoImageView.layer.borderColor  =  RGB(255, 255, 255).CGColor;
    [self.loginView addSubview: self.icoImageView];
    
    
    
    NSString *loginstr = [HWjianzhiduiObject keylocalization:@"登录" ];
    //  self.loginView.bottom+21
    UIButton *loginbutt  = [UIButton setButtonWithFrame:CGRectMake(50,self.loginView.bottom+20,kScreenW-100, 44) Title:loginstr Image:nil Font:15 Color:RGB(255, 255, 255) Target:self Selector:@selector(logtapTap:)];
    //  loginbutt.backgroundColor = RGB(68, 94, 233);
    //  [loginbutt setBackgroundImage:[UIImage imageNamed:@"button_s"] forState:UIControlStateNormal];
    //    loginbutt.layer.shadowColor = [UIColor colorWithRed:26/255.0 green:113/255.0 blue:255/255.0 alpha:0.35].CGColor;
    //    loginbutt.layer.shadowOffset = CGSizeMake(0,0);
    //    loginbutt.layer.shadowOpacity = 1;
    //    loginbutt.layer.shadowRadius = 10;
    //    loginbutt.layer.cornerRadius = 6;
    //    loginbutt.layer.masksToBounds = YES;
    //    loginbutt.clipsToBounds = NO;
    loginbutt.layer.masksToBounds = YES;
    loginbutt.layer.cornerRadius = 22;
    self.loginBut = loginbutt;
    [self.view addSubview:loginbutt];
    
    loginbutt.backgroundColor = QCchunseshensetupian;
    
    [self yonghuoXiYiYueyingseUiview];
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    UIView  *zhuceview  = [[UIView alloc]initWithFrame:CGRectMake((kScreenW -60-60-70)/2, 5+loginbutt.bottom, 60+60+70, 40)];
    zhuceview.hidden = YES;
    // zhuceview.backgroundColor = [UIColor redColor];
    [self.view addSubview:zhuceview];
    //    NSArray *arr =  @[@"账号注册",@"手机号注册",@" 游客登录"];
    NSArray *arr =  @[[HWjianzhiduiObject keylocalization:@"账号注册"],[HWjianzhiduiObject keylocalization:@"手机号注册"],@" 游客登录"];
    
    for (int i = 0; i < 3 ; i++) {
        UIButton *zhucebutt  = [UIButton setButtonWithFrame:CGRectMake(0,0,kScreenW-50, 40) Title:arr[i] Image:nil Font:13 Color:RGB(153, 153, 153) Target:self Selector:@selector(zhucebutttap:)];
        zhucebutt.tag = i;
        
        if (i == 0) {
            zhucebutt.frame = CGRectMake(0, 0, 60, 40);
        } else if (i == 1) {
            
            zhucebutt.frame = CGRectMake(60, 0, 70, 40);
        } else {
            
            zhucebutt.frame = CGRectMake(60+70, 0, 60, 40);
        }
        [zhuceview addSubview:zhucebutt];
        
        
    }
    
    
    
    for (int i = 0 ; i < 2; i++) {
        UIView  *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 1, 13)];
        view.backgroundColor = RGB(153, 153, 153);
        [zhuceview addSubview:view];
        
        if (i == 0) {
            
            
            view.frame = CGRectMake(59, 13, 1, 13);
            
        } else {
            
            view.frame = CGRectMake(59+70, 13, 1, 13);
        }
        
        
    }
    
    
    
    
    
    UIButton *weixingBut = [UIButton buttonWithType:UIButtonTypeCustom];
    weixingBut.frame = CGRectMake((self.view.frame.size.width-130)/2,self.view.height-70, 50, 50);
    // [weixingBut setTitle:@"忘记密码？" forState:UIControlStateNormal];
    //  [weixingBut setTitleColor:RGB(26, 113, 255) forState:UIControlStateNormal];
    weixingBut.titleLabel.font = [UIFont systemFontOfSize:12];
    [weixingBut addTarget:self action:@selector(weixingButtap:) forControlEvents:UIControlEventTouchUpInside];
    self.weixingBut = weixingBut;
    // wangjibutton.backgroundColor = [UIColor redColor];
    //  self.weixingBut.backgroundColor = [UIColor redColor];
    weixingBut.layer.cornerRadius = 25;
    weixingBut.layer.masksToBounds = YES;
    [weixingBut setBackgroundImage:[UIImage imageNamed:@"weixin"] forState:UIControlStateNormal];
    [self.view  addSubview:weixingBut];
    
    
    
    
    UIButton *QQBut = [UIButton buttonWithType:UIButtonTypeCustom];
    QQBut.frame = CGRectMake((self.view.frame.size.width-130)/2+80,self.view.height-70, 50, 50);
    // [weixingBut setTitle:@"忘记密码？" forState:UIControlStateNormal];
    //  [weixingBut setTitleColor:RGB(26, 113, 255) forState:UIControlStateNormal];
    QQBut.titleLabel.font = [UIFont systemFontOfSize:12];
    [QQBut addTarget:self action:@selector(QQButtap:) forControlEvents:UIControlEventTouchUpInside];
    self.QQBut = QQBut;
    // wangjibutton.backgroundColor = [UIColor redColor];
    //  self.weixingBut.backgroundColor = [UIColor redColor];
    QQBut.layer.cornerRadius = 25;
    QQBut.layer.masksToBounds = YES;
    [QQBut setBackgroundImage:[UIImage imageNamed:@"qq"] forState:UIControlStateNormal];
    [self.view  addSubview:QQBut];
    
    //  这两个暂时隐藏了
    self.weixingBut.hidden = YES;
    self.QQBut.hidden = YES;
    
    
    
    
    
    
    
    
    
    
}


// 添加监听事件
- (void)yonghuoXiYiYueyingseUiview  {
    
    
    //     NSString *str1 = @"登录即同意";
    //     NSString *str2 = @"“用户协议”";
    //     NSString *str3 = @"和";
    //     NSString *str4 = @"“隐私政策”";
    
    
    NSString *str1 =  [HWjianzhiduiObject keylocalization:@"登录即同意"];
    NSString *str2 = [HWjianzhiduiObject keylocalization:@"“用户协议”"];
    NSString *str3 = [HWjianzhiduiObject keylocalization:@"和"];
    NSString *str4 = [HWjianzhiduiObject keylocalization:@"“隐私政策”"];
    NSString *str = [NSString stringWithFormat:@"%@%@%@%@",str1,str2,str3,str4];
    
    
    
    NSRange range1 = [str rangeOfString:str1];
    
    NSRange range2 = [str rangeOfString:str2];
    
    NSRange range3 = [str rangeOfString:str3];
    
    NSRange range4 = [str rangeOfString:str4];
    
    UITextView *textView = [[UITextView alloc] init];
    
    
    //   textView.frame = CGRectMake(40, 100, 300, 50);
    textView.frame = CGRectMake((kScreenW-260)/2, self.loginBut.bottom+20, 260, 40);
    
    textView.editable = NO;
    
    textView.delegate = self;
    
    [self.view addSubview:textView];
    
    
    
    NSMutableAttributedString *mastring = [[NSMutableAttributedString alloc] initWithString:str attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14]}];
    
    [mastring addAttribute:NSForegroundColorAttributeName value:RGB(68, 68, 68) range:range1];
    
    [mastring addAttribute:NSForegroundColorAttributeName value:[UIColor yellowColor] range:range2];
    
    [mastring addAttribute:NSForegroundColorAttributeName value:RGB(68, 68, 68) range:range3];
    [mastring addAttribute:NSForegroundColorAttributeName value:[UIColor yellowColor] range:range4];
    
    
    // 1.必须要用前缀（firstPerson，secondPerson），随便写但是要有
    
    // 2.要有后面的方法，如果含有中文，url会无效，所以转码
    
    NSString *valueString1 = [[NSString stringWithFormat:@"firstPerson://%@",str2] stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLFragmentAllowedCharacterSet]];
    
    NSString *valueString3 = [[NSString stringWithFormat:@"secondPerson://%@",str4] stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLFragmentAllowedCharacterSet]];
    
    [mastring addAttribute:NSLinkAttributeName value:valueString1 range:range2];
    
    [mastring addAttribute:NSLinkAttributeName value:valueString3 range:range4];
    textView.attributedText = mastring;
    
    
    
    
    
    
    // 卖
    
    
}







- (BOOL)textView:(UITextView *)textView shouldInteractWithURL:(NSURL *)URL inRange:(NSRange)characterRange {
    
    if ([[URL scheme] isEqualToString:@"firstPerson"]) {
        
        NSString *titleString = [NSString stringWithFormat:@"你点击了第一个文字:%@",[URL host]];
        
        //   [self clickLinkTitle:titleString];
        
        
        HWWebViewGameViewController *webview = [[HWWebViewGameViewController alloc]init];
        webview.urlString = [NSString stringWithFormat:@"%@?ct=zhanwu&ac=agreement&id=1&language=%@",[HWOCGlobalConst baseUrl],[HWjianzhiduiObject returnLanguageAcquisition]];
        webview.gname =@"注册协议";
        webview.isPush = YES;
        webview.gname = [HWjianzhiduiObject keylocalization:@"注册协议"];
        webview.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:webview animated:YES];
        
        
        
        
        return NO;
        
    } else if ([[URL scheme] isEqualToString:@"secondPerson"]) {
        
        NSString *titleString = [NSString stringWithFormat:@"你点击了第二个文字:%@",[URL host]];
        
        HWWebViewGameViewController *webview = [[HWWebViewGameViewController alloc]init];
        webview.urlString = [NSString stringWithFormat:@"%@?ct=zhanwu&ac=agreement&id=2&language=%@",[HWOCGlobalConst baseUrl],[HWjianzhiduiObject returnLanguageAcquisition]];
        //  webview.gname =@"隐私协议";
        webview.gname = [HWjianzhiduiObject keylocalization:@"隐私协议"];
        
        webview.isPush = YES;
        webview.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:webview animated:YES];
        
        //   [self clickLinkTitle:titleString];
        
        return NO;
        
    }
    
    return YES;
    
}

- (void)clickLinkTitle:(NSString *)title {
    
    UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:title preferredStyle:UIAlertControllerStyleAlert];
    
    UIAlertAction *action = [UIAlertAction actionWithTitle:@"好的" style:UIAlertActionStyleCancel handler:nil];
    
    [alert addAction:action];
    
    [self presentViewController:alert animated:YES completion:nil];
    
}





- (void)navigaView  {
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(10,StatusBarHeight, 40, 44);
    // button.backgroundColor = [UIColor redColor];
    [button setImage:[UIImage imageNamed:@"fanyudetails_back"] forState:UIControlStateNormal];
    [button addTarget:self action:@selector(buttonTap) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button];
    
    UILabel *textlabel = [[UILabel alloc]initWithFrame:CGRectMake((kScreenW-70)/2, StatusBarHeight, 70, 44)];
    textlabel.text = @"登录";
    textlabel.textAlignment =  NSTextAlignmentCenter;
    textlabel.textColor = [UIColor whiteColor];
    textlabel.font = [UIFont systemFontOfSize:16];
    [self.view addSubview:textlabel];
    
    
    
    
    
    
    
    
    
}




//
- (void)buttonTap {
    
    
    [self.navigationController setNavigationBarHidden:NO animated:YES];
    [self.navigationController popViewControllerAnimated:YES];
    if (self.goBack) {
        //                if (self.goBack) {
        self.goBack();
        //            }
    }
    
}


#pragma  mark -------- 一些点击事件

//记住账号
- (void)buttonTap:(UIButton *)sender {
    
    if (sender.selected == YES) {
        
        sender.selected = NO;
        self.jizhuStr  = @"0";
        
        
    } else {
        
        sender.selected = YES;
        self.jizhuStr  = @"1";
        
        
    }
    
    
    
}


// 点击登录按钮
- (void)logtapTap:(UIButton *)sender {
    
    
    if(!(self.accounttextField.text.length > 0)) {
        
        [MBProgressHUD showError:@"请输入账号"];
        return;
    } else if (!(self.miaTexfeild.text.length > 0)) {
        
        [MBProgressHUD showError:@"请输入密码"];
        return;
        
    }
    
    DLog(@"登录按钮");
    
    NSString *user_nameStr = self.accounttextField.text;
    NSString *passwdStr = self.miaTexfeild.text;
    
    NSString *tStr = [NSString stringWithFormat:@"%ld",[WMUtil getTimeSp]];
    
    
    NSString *signStr = [NSString stringWithFormat:@"%@%@%ld%@",user_nameStr,passwdStr,[WMUtil getTimeSp],@"riowreopfdwrops21qe"];
    NSString  *signStrMd5  =   [WMUtil md5HexDigest:signStr];
    DLog(@"MD5 ：%@",signStrMd5);
    
    
    
    NSDictionary *parametes = @{
        @"ios" : @"1",
        @"user_name":user_nameStr,
        @"ct"  : @"app",
        @"ac" : @"login",
        @"passwd" :passwdStr,
        @"t" : tStr,
        @"sign" :signStrMd5,
        @"member_id":[HWLocallyStoredData getCode],
        
    };
    
    
    
    
    [HWWebUtils doGetWithParameters:parametes progress:nil success:^(id response) {
        
        
        
        NSString *codeStr =  [NSString stringWithFormat:@"%@",response[@"code"]];
        if ([codeStr intValue] == 1) {
            
            NSLog(@"%@",response);
            [MBProgressHUD showSuccess:@"登录成功"];
            
            [HWLocallyStoredData setUserID:response[@"data"]];
            
            
            if ([self.jizhuStr isEqualToString:@"1"]) {
                [HWLocallyStoredData setAccount:user_nameStr];
                
            }
            
            [self.navigationController popViewControllerAnimated:YES];
            if (self.goBack) {
                //                if (self.goBack) {
                self.goBack();
                //            }
            }
            
            
            
            
        } else {
            
            [MBProgressHUD showError:response[@"message"]];
            
            
            
        }
        
        
        
    } failure:^(NSString *error) {
        // [SVProgressHUD dismiss];
        
        [MBProgressHUD showSuccess:@"登录失败"];
        [MBProgressHUD hideHUD];
        
        
    }];
    
    
    
    
    
    
    
}




// 是否是明文
- (void)xianshyanjTap:(UIButton *)sende {
    
    if (sende.selected == YES) {
        
        sende.selected = NO;
        // 密码
        self.miaTexfeild.secureTextEntry = YES;
    } else {
        
        sende.selected = YES;
        // 明文
        
        self.miaTexfeild.secureTextEntry = NO;
    }
    
}


- (void)zhucebutttap:(UIButton *)sender {
    
    if (sender.tag == 0) {
        
        HWAccountRegisteredViewController *accountRegiste =[[HWAccountRegisteredViewController alloc]init];
        [self.navigationController pushViewController:accountRegiste animated:YES];
        
    } else  if(sender.tag == 1){
        
        HWPhoneRegisteredController *phoen = [[HWPhoneRegisteredController alloc]init];
        [self.navigationController pushViewController:phoen animated:YES];
        
    } else {
        
        
        
        NSString *tStr = [NSString stringWithFormat:@"%ld",[WMUtil getTimeSp]];
        NSString *sign = [NSString stringWithFormat:@"%@%@",tStr,@"fsd213ewdsadqwe2121213edsad"];
        
        NSString  *signStrMd5  =   [WMUtil md5HexDigest:sign];
        
        NSString *bundlePath = [[NSBundle mainBundle] bundlePath];
        
        NSString *path2 = [NSString stringWithFormat:@"%@/%@", bundlePath, @"coid"];
        
        NSFileManager *manager = [NSFileManager defaultManager];
        
        //        NSString *channel = @"";
        
        
        NSString *channel = [NSString string];
        if ([manager fileExistsAtPath:path2]) {
            NSArray *allPath =[manager subpathsAtPath:path2];
            //4.遍历所有的子路径
            for (NSString *subPath in allPath) {
                if ([subPath containsString:@"coid_"]) {
                    channel = [subPath substringFromIndex:@"coid_".length];
                    NSLog(@"文件夹名字%@+++",  channel);
                }
            }
        }
        if ([channel isEqual:@""]) {
            member_id = [NSString stringWithFormat:@"0"];
        } else {
            member_id = [NSString stringWithFormat:@"%@",channel];
        }
        NSLog(@"有值吗++%@+++", member_id);
        
        
        NSDictionary *parametes = @{
            @"ct" : @"app",
            @"ac" : @"shiwan",
            @"ios" : @"1",
            @"t" : tStr,
            @"str": [self randomStringWithLength:10],
            @"sign":signStrMd5,
            @"member_id":[HWLocallyStoredData getCode],
            
        };
        
        [HWWebUtils doGetWithParameters:parametes progress:nil success:^(id response) {
            
            
            NSString *codeStr =  [NSString stringWithFormat:@"%@",response[@"code"]];
            if ([codeStr intValue] == 1) {
                //  [SVProgressHUD showSuccessWithStatus:@"发送成功"];
                
                
                
                
                // [MBProgressHUD showSuccess:@"游客登录成功"];
                
                
                
                self.touristsView = [[HWTouristsView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, kScreenH)];
                self.touristsView.delegate = self;
                self.touristsView.dataDic = response[@"data"];
                [HWLocallyStoredData setUserID:response[@"data"][@"uid"]];
                
                [kKeyWindow addSubview:self.touristsView];
                
                
                
                
                
                NSLog(@"%@",response);
                
                
            } else {
                
                //    [SVProgressHUD showInfoWithStatus:response[@"message"]];
                [MBProgressHUD showError:response[@"message"]];
                
                NSLog(@"%@",response);
                
            }
            
            //  [SVProgressHUD dismiss];
            
            // [MBProgressHUD hideHUD];
            
            
        } failure:^(NSString *error) {
            // [SVProgressHUD dismiss];
            [MBProgressHUD hideHUD];
            
            
        }];
        
        
        
        
        
        
        //        self.touristsView = [[HWTouristsView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, kScreenH)];
        //        [kKeyWindow addSubview:self.touristsView];
        
    }
    
    
}


-(NSString *)randomStringWithLength:(NSInteger)len {
    NSString *letters = @"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
    NSMutableString *randomString = [NSMutableString stringWithCapacity: len];
    
    for (NSInteger i = 0; i < len; i++) {
        [randomString appendFormat: @"%C", [letters characterAtIndex: arc4random_uniform([letters length])]];
    }
    return randomString;
    
    
    
}



#pragma mark ---- 点击
-(void)jizhu {
    [self.navigationController popViewControllerAnimated:YES];
    
}

//#pragma  mark -----  iOS AES128加解密
////加密
//+(NSString *)AES128Encrypt:(NSString *)plainText key:(NSString *)key
//{
//    char keyPtr[kCCKeySizeAES128+1];
//    memset(keyPtr, 0, sizeof(keyPtr));
//    [key getCString:keyPtr maxLength:sizeof(keyPtr) encoding:NSUTF8StringEncoding];
//
//    NSData* data = [plainText dataUsingEncoding:NSUTF8StringEncoding];
//    NSUInteger dataLength = [data length];
//
//    size_t bufferSize = dataLength + kCCBlockSizeAES128;
//    void *buffer = malloc(bufferSize);
//    size_t numBytesEncrypted = 0;
//    CCCryptorStatus cryptStatus = CCCrypt(kCCEncrypt,
//                                          kCCAlgorithmAES128,
//                                          kCCOptionPKCS7Padding|kCCOptionECBMode,
//                                          keyPtr,
//                                          kCCBlockSizeAES128,
//                                          NULL,
//                                          [data bytes],
//                                          dataLength,
//                                          buffer,
//                                          bufferSize,
//                                          &numBytesEncrypted);
//    if (cryptStatus == kCCSuccess) {
//        NSData *resultData = [NSData dataWithBytesNoCopy:buffer length:numBytesEncrypted];
//        //return [GTMBase64 stringByEncodingData:resultData];
//        return [self hexStringFromData:resultData];
//
//    }
//    free(buffer);
//    return nil;
//}
//


#pragma mark --------- 忘记密码
- (void)wangjibuttonTap {
    
    NSLog(@"忘记密码");
    //    HWVerificationViewController  *verifica = [[HWVerificationViewController alloc]init];
    //    [self.navigationController pushViewController:verifica animated:YES];
    //
    //
    HWForgotPasswordViewController *forgotPassword = [[HWForgotPasswordViewController alloc]init];
    [self.navigationController pushViewController:forgotPassword animated:YES];
    
    
    
    
}




- (void)weixingButtap:(UIButton *)sender {
    
    [self login];
    
    
    
    
    
}







- (void)QQButtap:(UIButton *)sender {
    
    NSLog(@"QQ");
    
    [self QQlogin];
    
    
    
    
}


// 微信
- (void)login{
    //判断微信是否安装
    if([WXApi isWXAppInstalled]){
        SendAuthReq *req = [[SendAuthReq alloc] init];
        req.scope = @"snsapi_userinfo";
        req.state = @"App";
//        [WXApi sendAuthReq:req viewController:self delegate:self];
        [WXApi sendAuthReq:req viewController:self delegate:self completion:^(BOOL success) {
            
        }];
        
        
    }else{
        [self setupAlertController];
    }
}

- (void)setupAlertController{
    UIAlertController *vc = [UIAlertController alertControllerWithTitle:@"温馨提示" message:@"请先安装微信客户端" preferredStyle:UIAlertControllerStyleAlert];
    UIAlertAction *actionConfim = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:nil];
    [vc addAction:actionConfim];
    [self presentViewController:vc animated:YES completion:nil];
}

- (void)wxLogin:(NSNotification*)noti{
    //获取到code
    SendAuthResp *resp = noti.object;
    NSLog(@"%@",resp.code);
    _code = resp.code;
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    NSString *url = [NSString stringWithFormat:@"https://api.weixin.qq.com/sns/oauth2/access_token?appid=%@&secret=%@&code=%@&grant_type=%@",weixiappId,appSecret,_code,@"authorization_code"];
    manager.requestSerializer = [AFJSONRequestSerializer serializer];
    [manager.requestSerializer setValue:@"text/html; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
    
    NSMutableSet *mgrSet = [NSMutableSet set];
    mgrSet.set = manager.responseSerializer.acceptableContentTypes;
    [mgrSet addObject:@"text/html"];
    //因为微信返回的参数是text/plain 必须加上 会进入fail方法
    [mgrSet addObject:@"text/plain"];
    [mgrSet addObject:@"application/json"];
    manager.responseSerializer.acceptableContentTypes = mgrSet;
    
    [manager GET:url parameters:nil  headers:nil progress:^(NSProgress * _Nonnull downloadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSLog(@"success");
        NSDictionary *resp = (NSDictionary*)responseObject;
        NSString *openid = resp[@"openid"];
        NSString *unionid = resp[@"unionid"];
        NSString *accessToken = resp[@"access_token"];
        NSString *refreshToken = resp[@"refresh_token"];
        if(accessToken && ![accessToken isEqualToString:@""] && openid && ![openid isEqualToString:@""]){
            [[NSUserDefaults standardUserDefaults] setObject:openid forKey:WX_OPEN_ID];
            [[NSUserDefaults standardUserDefaults] setObject:accessToken forKey:WX_ACCESS_TOKEN];
            [[NSUserDefaults standardUserDefaults] setObject:refreshToken forKey:WX_REFRESH_TOKEN];
            [[NSUserDefaults standardUserDefaults] synchronize];
        }
        [self getUserInfo];
        
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
    }];
    
}

- (void)authAccessToken{
    //验证accessToken是否是成功
    NSString *accessToken = [[NSUserDefaults standardUserDefaults] objectForKey:WX_ACCESS_TOKEN];
    NSString *openid = [[NSUserDefaults standardUserDefaults] objectForKey:WX_OPEN_ID];
    if(!accessToken || [accessToken isEqualToString:@""] || !openid || [openid isEqualToString:@""]){
        //如果没登陆过，则登陆
        [self login];
    }else{
        //否则验证access token 是否还有效
        AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
        NSString *url = [NSString stringWithFormat:@"https://api.weixin.qq.com/sns/auth?access_token=%@&openid=%@",accessToken,openid];
        
        NSMutableSet *mgrSet = [NSMutableSet set];
        mgrSet.set = manager.responseSerializer.acceptableContentTypes;
        [mgrSet addObject:@"text/html"];
        //因为微信返回的参数是text/plain 必须加上 会进入fail方法
        [mgrSet addObject:@"text/plain"];
        [mgrSet addObject:@"application/json"];
        manager.responseSerializer.acceptableContentTypes = mgrSet;
        
        [manager GET:url parameters:nil headers:nil progress:^(NSProgress * _Nonnull downloadProgress) {
            
        } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
            NSLog(@"success");
            NSDictionary *resp = (NSDictionary*)responseObject;
            if([resp[@"errcode"] intValue] == 0){
                //有效则直接获取信息
                [self getUserInfo];
            }else{
                //否则使用refreshtoken来刷新accesstoken
                [self refreshAccessToken];
            }
        } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
            NSLog(@"fail");
            NSLog(@"%@",task.response);
        }];
    }
    
    
}

- (IBAction)refreshAccessToken:(UIButton *)sender {
    
    [self refreshAccessToken];
    
}

- (void)refreshAccessToken{
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    NSString *url = [NSString stringWithFormat:@"https://api.weixin.qq.com/sns/oauth2/refresh_token?appid=%@&refresh_token=%@&grant_type=%@",[[NSUserDefaults standardUserDefaults] objectForKey:WX_OPEN_ID],[[NSUserDefaults standardUserDefaults] objectForKey:WX_REFRESH_TOKEN],@"REFRESH_TOKEN"];
    
    NSMutableSet *mgrSet = [NSMutableSet set];
    mgrSet.set = manager.responseSerializer.acceptableContentTypes;
    [mgrSet addObject:@"text/html"];
    //因为微信返回的参数是text/plain 必须加上 会进入fail方法
    [mgrSet addObject:@"text/plain"];
    [mgrSet addObject:@"application/json"];
    manager.responseSerializer.acceptableContentTypes = mgrSet;
    
    [manager GET:url parameters:nil headers:nil progress:^(NSProgress * _Nonnull downloadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSLog(@"success");
        NSDictionary *resp = (NSDictionary*)responseObject;
        NSString *openid = resp[@"openid"];
        NSString *accessToken = resp[@"access_token"];
        NSString *refreshToken = resp[@"refresh_token"];
        if(refreshToken){
            if(accessToken && ![accessToken isEqualToString:@""] && openid && ![openid isEqualToString:@""]){
                [[NSUserDefaults standardUserDefaults] setObject:openid forKey:WX_OPEN_ID];
                [[NSUserDefaults standardUserDefaults] setObject:accessToken forKey:WX_ACCESS_TOKEN];
                [[NSUserDefaults standardUserDefaults] setObject:refreshToken forKey:WX_REFRESH_TOKEN];
                [[NSUserDefaults standardUserDefaults] synchronize];
            }
        }else{
            //如果refreshToken为空，说明refreshToken也过期了，需要重新登陆
            [self login];
        }
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        NSLog(@"fail");
        NSLog(@"%@",task.response);
    }];
}

- (IBAction)getUserInfo:(UIButton *)sender {
    [self getUserInfo];
}

- (void)getUserInfo{
    //获取个人信息
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    NSString *url = [NSString stringWithFormat:@"https://api.weixin.qq.com/sns/userinfo?access_token=%@&openid=%@",[[NSUserDefaults standardUserDefaults] objectForKey:WX_ACCESS_TOKEN],[[NSUserDefaults standardUserDefaults] objectForKey:WX_OPEN_ID]];
    
    NSMutableSet *mgrSet = [NSMutableSet set];
    mgrSet.set = manager.responseSerializer.acceptableContentTypes;
    [mgrSet addObject:@"text/html"];
    //因为微信返回的参数是text/plain 必须加上 会进入fail方法
    [mgrSet addObject:@"text/plain"];
    [mgrSet addObject:@"application/json"];
    manager.responseSerializer.acceptableContentTypes = mgrSet;
    
    [manager GET:url parameters:nil headers:nil progress:^(NSProgress * _Nonnull downloadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSLog(@"success");
        
        NSLog(@"%@",responseObject);
        NSDictionary *resp = (NSDictionary*)responseObject;
        //        self->_nicknameLabel.text = resp[@"nickname"];
        //        self->_sexLabel.text = [resp[@"sex"] intValue] == 1 ? @"男" : @"女";
        //        self->_addressLabel.text = [NSString stringWithFormat:@"%@%@%@",resp[@"country"],resp[@"province"],resp[@"city"]];
        [self fasongwangluoqingqiu:resp];
        
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        NSLog(@"fail");
        NSLog(@"%@",task.response);
    }];
}

// 微信登录
- (void)fasongwangluoqingqiu:(NSDictionary *)dic {
    
    
    
    
    self.weixingaccessTokenStr = [NSString stringWithFormat:@"%@",dic[@"unionid"]];
    [self weixingdenglupanduan];
    
    
    return;
    
    NSDictionary *parametes = @{
        @"ct" : @"azwxlogin",
        @"ios" : @"1",
        @"type": @"2",
        @"openid":dic[@"unionid"],
        @"member_id":[HWLocallyStoredData getCode],
        
    };
    
    [HWWebUtils doGetWithParameters:parametes progress:nil success:^(id response) {
        
        
        NSString *codeStr =  [NSString stringWithFormat:@"%@",response[@"code"]];
        if ([codeStr intValue] == 1) {
            //  [SVProgressHUD showSuccessWithStatus:@"发送成功"];
            
            
            NSLog(@"%@",response);
            
            // [MBProgressHUD showSuccess:@"游客登录成功"];
            
            
            
            //    [MBProgressHUD showSuccess:response[@"message"]];
            
            [HWLocallyStoredData setUserID:response[@"data"]];
            
            
            
            [self.navigationController popViewControllerAnimated:YES];
            if (self.goBack) {
                //                if (self.goBack) {
                self.goBack();
                //            }
            }
            
            
            
            
            
            NSLog(@"%@",response);
            
            
        } else {
            
            //    [SVProgressHUD showInfoWithStatus:response[@"message"]];
            [MBProgressHUD showError:response[@"message"]];
            
            NSLog(@"%@",response);
            
        }
        
        //  [SVProgressHUD dismiss];
        
        // [MBProgressHUD hideHUD];
        
        
    } failure:^(NSString *error) {
        // [SVProgressHUD dismiss];
        [MBProgressHUD hideHUD];
        
        
    }];
    
    
    
    
    
    
    
}

// 微信判断
- (void)weixingdenglupanduan {
    
    
    NSDictionary *parametes = @{
        @"ct" : @"app",
        @"ios" : @"1",
        @"ac": @"is_reg",
        @"type": @"2",
        @"member_id":[HWLocallyStoredData getCode],
        @"str":self.weixingaccessTokenStr,
        
        
    };
    
    [HWWebUtils do3GetWithParameters:parametes progress:nil success:^(id response) {
        
        
        NSString *codeStr =  [NSString stringWithFormat:@"%@",response[@"code"]];
        if ([codeStr intValue] == 1) {
            //  [SVProgressHUD showSuccessWithStatus:@"发送成功"];
            
            //   [self zuixingQQdenglu];
            
            NSLog(@"%@",response);
            
            // [MBProgressHUD showSuccess:@"游客登录成功"];
            
            
            
            //    [MBProgressHUD showSuccess:response[@"message"]];
            
            //     [HWLocallyStoredData setUserID:response[@"data"]];
            
            
            
            //  [self.navigationController popViewControllerAnimated:YES];
            
            [self zuixingweixingdenglu];
            
            
            
            
            NSLog(@"%@",response);
            
            
        } else if ([codeStr intValue] == 0){
            
            HWSetcodeAndPasswordViewController *phone =  [[HWSetcodeAndPasswordViewController alloc]init];
            // phone.dataStr = self.dataStr;
            phone.panduanStr = @"2";
            phone.accessTokenStr =  self.weixingaccessTokenStr;
            [[[HWViewUtils  getCurrentVC] navigationController]  pushViewController:phone animated:NO];
            
            
            
        }else {
            
            //    [SVProgressHUD showInfoWithStatus:response[@"message"]];
            [MBProgressHUD showError:response[@"message"]];
            
            NSLog(@"%@",response);
            
        }
        
        //  [SVProgressHUD dismiss];
        
        // [MBProgressHUD hideHUD];
        
        
    } failure:^(NSString *error) {
        // [SVProgressHUD dismiss];
        [MBProgressHUD hideHUD];
        
        
    }];
    
    
    
    
    
}


- (void)zuixingweixingdenglu {
    
    
    NSDictionary *parametes = @{
        @"ct" : @"azwxlogin",
        @"ios" : @"1",
        @"type": @"2",
        @"openid":self.weixingaccessTokenStr,
        @"member_id":[HWLocallyStoredData getCode],
        
    };
    
    [HWWebUtils doGetWithParameters:parametes progress:nil success:^(id response) {
        
        
        NSString *codeStr =  [NSString stringWithFormat:@"%@",response[@"code"]];
        if ([codeStr intValue] == 1) {
            //  [SVProgressHUD showSuccessWithStatus:@"发送成功"];
            
            
            NSLog(@"%@",response);
            
            // [MBProgressHUD showSuccess:@"游客登录成功"];
            
            
            
            //    [MBProgressHUD showSuccess:response[@"message"]];
            
            [HWLocallyStoredData setUserID:response[@"data"]];
            
            
            
            [self.navigationController popViewControllerAnimated:YES];
            if (self.goBack) {
                self.goBack();
            }
            
            
            
            
            NSLog(@"%@",response);
            
            
        } else {
            
            //    [SVProgressHUD showInfoWithStatus:response[@"message"]];
            [MBProgressHUD showError:response[@"message"]];
            
            NSLog(@"%@",response);
            
        }
        
        //  [SVProgressHUD dismiss];
        
        // [MBProgressHUD hideHUD];
        
        
    } failure:^(NSString *error) {
        // [SVProgressHUD dismiss];
        [MBProgressHUD hideHUD];
        
        
    }];
    
    
    
    
}









- (void)QQlogin {
    
    //  #define  QQAPPID @"101574270"
    
    NSLog(@"QQ登录");
    
    _tencentOAuth = [[TencentOAuth alloc]initWithAppId:QQAPPID andDelegate:self];
    
    NSArray *permissions = [NSArray arrayWithObjects:kOPEN_PERMISSION_GET_INFO, kOPEN_PERMISSION_GET_USER_INFO, kOPEN_PERMISSION_GET_SIMPLE_USER_INFO, nil];
    // 这里调起登录
    [_tencentOAuth authorize:permissions];
    
    
    
    
    
}


- (void)tencentDidLogin
{
    if (_tencentOAuth.accessToken.length > 0) {
        // 获取用户信息
        //   [_tencentOAuth getUserInfo];
        
        [self QQDengluToken:_tencentOAuth.accessToken];
        
        
        
        
    } else {
        NSLog(@"登录不成功 没有获取accesstoken");
    }
}

//非网络错误导致登录失败：
- (void)tencentDidNotLogin:(BOOL)cancelled {
    if (cancelled) {
        NSLog(@"用户取消登录");
    } else {
        NSLog(@"登录失败");
    }
    
}


- (void)getUserInfoResponse:(APIResponse *)response {
    
    if (response && response.retCode == URLREQUEST_SUCCEED) {
        
        NSDictionary *userInfo = [response jsonResponse];
        NSString *nickName = userInfo[@"nickname"];
        
        // 后续操作...
        
        
    } else {
        NSLog(@"QQ auth fail ,getUserInfoResponse:%d", response.detailRetCode);
    }
    
}




- (void)QQDengluToken:(NSString *)accessToken {
    
    
    self.QQaccessTokenStr = accessToken;
    
    
    [self QQDengluTokenchaxun:accessToken];
    
    
    
    
    
    
    
    return;
    NSDictionary *parametes = @{
        @"ct" : @"azwxlogin",
        @"ios" : @"1",
        @"type": @"1",
        @"openid":accessToken,
        @"member_id":[HWLocallyStoredData getCode],
        
    };
    
    [HWWebUtils doGetWithParameters:parametes progress:nil success:^(id response) {
        
        
        NSString *codeStr =  [NSString stringWithFormat:@"%@",response[@"code"]];
        if ([codeStr intValue] == 1) {
            //  [SVProgressHUD showSuccessWithStatus:@"发送成功"];
            
            
            NSLog(@"%@",response);
            
            // [MBProgressHUD showSuccess:@"游客登录成功"];
            
            
            
            //    [MBProgressHUD showSuccess:response[@"message"]];
            
            [HWLocallyStoredData setUserID:response[@"data"]];
            
            
            
            [self.navigationController popViewControllerAnimated:YES];
            if (self.goBack) {
                self.goBack();
            }
            
            
            
            
            NSLog(@"%@",response);
            
            
        } else {
            
            //    [SVProgressHUD showInfoWithStatus:response[@"message"]];
            [MBProgressHUD showError:response[@"message"]];
            
            NSLog(@"%@",response);
            
        }
        
        //  [SVProgressHUD dismiss];
        
        // [MBProgressHUD hideHUD];
        
        
    } failure:^(NSString *error) {
        // [SVProgressHUD dismiss];
        [MBProgressHUD hideHUD];
        
        
    }];
    
    
    
    
    
    
}


-(void)QQDengluTokenchaxun:(NSString *)accessToken  {
    
    
    NSDictionary *parametes = @{
        @"ct" : @"app",
        @"ios" : @"1",
        @"ac": @"is_reg",
        @"type": @"2",
        @"member_id":[HWLocallyStoredData getCode],
        @"str":accessToken,
        
        
    };
    
    [HWWebUtils do3GetWithParameters:parametes progress:nil success:^(id response) {
        
        
        NSString *codeStr =  [NSString stringWithFormat:@"%@",response[@"code"]];
        if ([codeStr intValue] == 1) {
            //  [SVProgressHUD showSuccessWithStatus:@"发送成功"];
            
            [self zuixingQQdenglu];
            
            NSLog(@"%@",response);
            
            // [MBProgressHUD showSuccess:@"游客登录成功"];
            
            
            
            //    [MBProgressHUD showSuccess:response[@"message"]];
            
            //     [HWLocallyStoredData setUserID:response[@"data"]];
            
            
            
            //  [self.navigationController popViewControllerAnimated:YES];
            
            
            
            
            
            NSLog(@"%@",response);
            
            
        } else if ([codeStr intValue] == 0){
            
            HWSetcodeAndPasswordViewController *phone =  [[HWSetcodeAndPasswordViewController alloc]init];
            // phone.dataStr = self.dataStr;
            phone.panduanStr = @"1";
            phone.accessTokenStr = accessToken;
            [[[HWViewUtils  getCurrentVC] navigationController]  pushViewController:phone animated:NO];
            
            
            
        }else {
            
            //    [SVProgressHUD showInfoWithStatus:response[@"message"]];
            [MBProgressHUD showError:response[@"message"]];
            
            NSLog(@"%@",response);
            
        }
        
        //  [SVProgressHUD dismiss];
        
        // [MBProgressHUD hideHUD];
        
        
    } failure:^(NSString *error) {
        // [SVProgressHUD dismiss];
        [MBProgressHUD hideHUD];
        
        
    }];
    
    
    
}


- (void)zuixingQQdenglu {
    
    NSDictionary *parametes = @{
        @"ct" : @"azwxlogin",
        @"ios" : @"1",
        @"type": @"1",
        @"openid":self.QQaccessTokenStr,
        @"member_id":[HWLocallyStoredData getCode],
        
    };
    
    [HWWebUtils doGetWithParameters:parametes progress:nil success:^(id response) {
        
        
        NSString *codeStr =  [NSString stringWithFormat:@"%@",response[@"code"]];
        if ([codeStr intValue] == 1) {
            //  [SVProgressHUD showSuccessWithStatus:@"发送成功"];
            
            
            NSLog(@"%@",response);
            
            // [MBProgressHUD showSuccess:@"游客登录成功"];
            
            
            
            //    [MBProgressHUD showSuccess:response[@"message"]];
            
            [HWLocallyStoredData setUserID:response[@"data"]];
            
            
            
            [self.navigationController popViewControllerAnimated:YES];
            if (self.goBack) {
                self.goBack();
            }
            
            
            
            
            NSLog(@"%@",response);
            
            
        } else {
            
            //    [SVProgressHUD showInfoWithStatus:response[@"message"]];
            [MBProgressHUD showError:response[@"message"]];
            
            NSLog(@"%@",response);
            
        }
        
        //  [SVProgressHUD dismiss];
        
        // [MBProgressHUD hideHUD];
        
        
    } failure:^(NSString *error) {
        // [SVProgressHUD dismiss];
        [MBProgressHUD hideHUD];
        
        
    }];
    
    
    
}








@end





#pragma  mark -----------  以前的登录界面


//#import "HWLoginController.h"
//#import "HWAccountRegisteredViewController.h"
//#import  "HWPhoneRegisteredController.h"
//#import "HWTouristsView.h"
//#import "HWVerificationViewController.h"
//#import "HWForgotPasswordViewController.h" // 忘记密码
//#import "WXApi.h"
//
//#import <TencentOpenAPI/TencentOAuth.h>
//
// // #import <CL_ShanYanSDK/CL_ShanYanSDK.h>
//
////引入JVERIFICATIONService.h头文件
//#import "JVERIFICATIONService.h"
//// 如果需要使用 idfa 功能所需要引入的头文件（可选）
//#import <AdSupport/AdSupport.h>
//
//
//
//@interface HWLoginController ()<HWTouristsViewDelegate,WXApiDelegate,TencentSessionDelegate>
//{
//
//     NSString *member_id; //推广id
//     NSString *_code;
//
//}
//@property(strong,nonatomic) UIView *loginView;
//@property(strong,nonatomic) UIImageView *icoImageView;
//@property(strong,nonatomic) UITextField *accounttextField; // 账号
//@property(strong,nonatomic) UITextField *miaTexfeild;
//@property(strong,nonatomic) HWTouristsView *touristsView;
//@property(strong,nonatomic) NSString *jizhuStr; // 是否选中账号
//
//@property(strong,nonatomic)UIButton *weixingBut; // 微信登录
//@property(strong,nonatomic)UIButton *QQBut;  // QQ登录
//
//@property(nonatomic, strong) TencentOAuth * tencentOAuth;
//
//@end
//
//@implementation HWLoginController
//
//- (void)viewWillAppear:(BOOL)animated {
//    [super viewWillAppear:animated];
//
//    [self.navigationController setNavigationBarHidden:YES ];
//}
//
//- (void)viewWillDisappear:(BOOL)animated {
//    [super viewWillDisappear:animated];
//     [self.navigationController setNavigationBarHidden:NO];
//
//   // [self.navigationController setNavigationBarHidden:NO animated:animated];
//}
//
//- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
//    [self.view endEditing:YES];
//
//}
//
//
//- (void)viewDidLoad {
//    [super viewDidLoad];
//
////    [self setupUI];
////    // shezhi
////    [self navigaView];
//
//
//
//        //预取号
////    [CLShanYanSDKManager preGetPhonenumber:^(CLCompleteResult * _Nonnull completeResult) {
////
////
////     //    [self quickLoginBtnClick:nil];
////        [NSThread currentThread];
//////         dispatch_async(dispatch_get_main_queue(), ^{
//////              [self quickLoginBtnClick];
//////        });
////      //    [self quickLoginBtnClick];
////       //  [self performSelector:@selector(quickLoginBtnClick) withObject:nil afterDelay:2];
////
////    }];
//
//
//     [self setupUI];
//     // shezhi
//     [self navigaView];
//
//
//
//
//
////       [self performSelector:@selector(quickLoginBtnClick) withObject:nil afterDelay:2];
//
//    // 手机网游  BT游戏  折扣游戏  H5游戏
//     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(wxLogin:) name:@"wxLogin" object:nil];
//
//    //先判断之前是否登录过
// //   [self authAccessToken];
//
//
//    [self chaxunshipingyijiandenglu];
//
//
//    [self customWindowUI];
//
//
//
//
//
//}
//
//
//
//
//- (void)customWindowUI  {
//
//       JVUIConfig *config = [[JVUIConfig alloc] init];
//          config.navCustom = NO;
//      //    config.prefersStatusBarHidden = YES;
//          config.shouldAutorotate = YES;
//          config.autoLayout = YES;
//      //    config.orientation =  UIInterfaceOrientationPortrait;
//
//          config.navReturnHidden = NO;
//          config.privacyTextFontSize = 12;
//          config.navText = [[NSAttributedString alloc]initWithString:@"登录统一认证" attributes:@{NSForegroundColorAttributeName:[UIColor whiteColor], NSFontAttributeName:[UIFont systemFontOfSize:18]}];
//      //    config.navColor = [UIColor redColor];
//      //    config.navBarBackGroundImage = [UIImage imageNamed:@"cmccLogo"];
//          config.privacyTextAlignment = NSTextAlignmentLeft;
//      //    config.numberFont = [UIFont systemFontOfSize:10];
//      //    config.logBtnFont = [UIFont systemFontOfSize:5];
//      //    config.privacyShowBookSymbol = YES;
//      //    config.privacyLineSpacing = 5;
//      //    config.agreementNavBackgroundColor = [UIColor redColor];
//      //    config.sloganFont = [UIFont systemFontOfSize:30];
//      //    config.checkViewHidden = YES;
//          config.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
//
//          /*
//          config.customLoadingViewBlock = ^(UIView *View) {
//
//              //https://github.com/jdg/MBProgressHUD
//              MBProgressHUD *hub = [MBProgressHUD showHUDAddedTo:View animated:YES];
//              hub.backgroundColor = [UIColor clearColor];
//              hub.label.text = @"正在登录..";
//              [hub showAnimated:YES];
//          };
//          */
//
//          /*
//          config.customPrivacyAlertViewBlock = ^(UIViewController *vc) {
//              UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"请点击同意协议" message:nil preferredStyle:UIAlertControllerStyleAlert];
//              [alert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:nil]];
//              [vc presentViewController:alert animated:true completion:nil];
//          };
//          */
//
//
//          //logo
//          config.logoImg = [UIImage imageNamed:@"cmccLogo"];
//          CGFloat logoWidth = config.logoImg.size.width?:100;
//          CGFloat logoHeight = logoWidth;
//          JVLayoutConstraint *logoConstraintX = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterX multiplier:1 constant:0];
//          JVLayoutConstraint *logoConstraintY = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterY multiplier:1 constant:-90];
//          JVLayoutConstraint *logoConstraintW = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeWidth multiplier:1 constant:logoWidth];
//          JVLayoutConstraint *logoConstraintH = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeHeight multiplier:1 constant:logoHeight];
//          config.logoConstraints = @[logoConstraintX,logoConstraintY,logoConstraintW,logoConstraintH];
//          config.logoHorizontalConstraints = config.logoConstraints;
//
//
//
//          //号码栏
//          JVLayoutConstraint *numberConstraintX = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterX multiplier:1 constant:0];
//          JVLayoutConstraint *numberConstraintY = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterY multiplier:1 constant:-55];
//          JVLayoutConstraint *numberConstraintW = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeWidth multiplier:1 constant:130];
//          JVLayoutConstraint *numberConstraintH = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeHeight multiplier:1 constant:25];
//          config.numberConstraints = @[numberConstraintX,numberConstraintY, numberConstraintW, numberConstraintH];
//          config.numberHorizontalConstraints = config.numberConstraints;
//
//          //slogan展示
//          JVLayoutConstraint *sloganConstraintX = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterX multiplier:1 constant:0];
//          JVLayoutConstraint *sloganConstraintY = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterY multiplier:1 constant:-20];
//          JVLayoutConstraint *sloganConstraintW = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeWidth multiplier:1 constant:130];
//          JVLayoutConstraint *sloganConstraintH = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeHeight multiplier:1 constant:20];
//          config.sloganConstraints = @[sloganConstraintX,sloganConstraintY, sloganConstraintW, sloganConstraintH];
//          config.sloganHorizontalConstraints = config.sloganConstraints;
//
//
//          //登录按钮
//          UIImage *login_nor_image = [self imageNamed1:@"loginBtn_Nor"];
//          UIImage *login_dis_image = [self imageNamed1:@"loginBtn_Dis"];
//          UIImage *login_hig_image = [self imageNamed1:@"loginBtn_Hig"];
//          if (login_nor_image && login_dis_image && login_hig_image) {
//              config.logBtnImgs = @[login_nor_image, login_dis_image, login_hig_image];
//          }
//          CGFloat loginButtonWidth = login_nor_image.size.width?:100;
//          CGFloat loginButtonHeight = login_nor_image.size.height?:100;
//          JVLayoutConstraint *loginConstraintX = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterX multiplier:1 constant:0];
//          JVLayoutConstraint *loginConstraintY = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterY multiplier:1 constant:30];
//          JVLayoutConstraint *loginConstraintW = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeWidth multiplier:1 constant:loginButtonWidth];
//          JVLayoutConstraint *loginConstraintH = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeHeight multiplier:1 constant:loginButtonHeight];
//          config.logBtnConstraints = @[loginConstraintX,loginConstraintY,loginConstraintW,loginConstraintH];
//          config.logBtnHorizontalConstraints = config.logBtnConstraints;
//
//          //勾选框
//          UIImage * uncheckedImg = [self imageNamed1:@"checkBox_unSelected"];
//          UIImage * checkedImg = [self imageNamed1:@"checkBox_selected"];
//          CGFloat checkViewWidth = uncheckedImg.size.width;
//          CGFloat checkViewHeight = uncheckedImg.size.height;
//          config.uncheckedImg = uncheckedImg;
//          config.checkedImg = checkedImg;
//          JVLayoutConstraint *checkViewConstraintX = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeLeft multiplier:1 constant:20];
//          JVLayoutConstraint *checkViewConstraintY = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemPrivacy attribute:NSLayoutAttributeCenterY multiplier:1 constant:0];
//          JVLayoutConstraint *checkViewConstraintW = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeWidth multiplier:1 constant:checkViewWidth];
//          JVLayoutConstraint *checkViewConstraintH = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeHeight multiplier:1 constant:checkViewHeight];
//          config.checkViewConstraints = @[checkViewConstraintX,checkViewConstraintY,checkViewConstraintW,checkViewConstraintH];
//          config.checkViewHorizontalConstraints = config.checkViewConstraints;
//
//
//          //隐私
//          CGFloat spacing = checkViewWidth + 20 + 5;
//          config.privacyState = YES;
//
//          JVLayoutConstraint *privacyConstraintX = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeLeft multiplier:1 constant:spacing];
//          JVLayoutConstraint *privacyConstraintX2 = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeRight multiplier:1 constant:-spacing];
//          JVLayoutConstraint *privacyConstraintY = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeBottom multiplier:1 constant:-10];
//          JVLayoutConstraint *privacyConstraintH = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeHeight multiplier:1 constant:50];
//          config.privacyConstraints = @[privacyConstraintX,privacyConstraintX2,privacyConstraintY,privacyConstraintH];
//          config.privacyHorizontalConstraints = config.privacyConstraints;
//
//
//          //loading
//          JVLayoutConstraint *loadingConstraintX = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterX multiplier:1 constant:0];
//          JVLayoutConstraint *loadingConstraintY = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterY multiplier:1 constant:0];
//          JVLayoutConstraint *loadingConstraintW = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeWidth multiplier:1 constant:30];
//          JVLayoutConstraint *loadingConstraintH = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeHeight multiplier:1 constant:30];
//          config.loadingConstraints = @[loadingConstraintX,loadingConstraintY,loadingConstraintW,loadingConstraintH];
//          config.loadingHorizontalConstraints = config.loadingConstraints;
//
//
//          /*
//          config.authPageBackgroundImage = [UIImage imageNamed:@"背景图"];
//          config.navColor = [UIColor redColor];
//          config.preferredStatusBarStyle = 0;
//          config.navText = [[NSAttributedString alloc] initWithString:@"自定义标题"];
//          config.navReturnImg = [UIImage imageNamed:@"自定义返回键"];
//          UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
//          button.frame = CGRectMake(0, 0, 44, 44);
//          button.backgroundColor = [UIColor greenColor];
//          config.navControl = [[UIBarButtonItem alloc] initWithCustomView:button];
//          config.logoHidden = NO;
//          config.logBtnText = @"自定义登录按钮文字";
//          config.logBtnTextColor = [UIColor redColor];
//          config.numberColor = [UIColor blueColor];
//          config.appPrivacyOne = @[@"应用自定义服务条款1",@"https://www.jiguang.cn/about"];
//          config.appPrivacyTwo = @[@"应用自定义服务条款2",@"https://www.jiguang.cn/about"];
//          config.privacyComponents = @[@"文本1",@"文本2",@"文本3",@"文本4"];
//          config.appPrivacyColor = @[[UIColor redColor], [UIColor blueColor]];
//          config.sloganTextColor = [UIColor redColor];
//          config.navCustom = NO;
//          config.numberSize = 24;
//          config.privacyState = YES;
//           */
//
//
//      [JVERIFICATIONService customUIWithConfig:config customViews:^(UIView *customAreaView) {
//              /*
//              //添加一个自定义label
//              UILabel *lable  = [[UILabel alloc] init];
//              lable.text = @"这是一个自定义label";
//              [lable sizeToFit];
//              lable.center = customAreaView.center;
//              [customAreaView addSubview:lable];
//               */
//
//        }];
//
//
//
//
//
//}
//
//
//
//
//- (UIImage *)imageNamed1:(NSString *)nameStr  {
//
//
//    // NSBundle *bundlePath = [[NSBundle mainBundle]pathForResource:@"JVerificationResource" ofType:@"bundle"];
//
//     // UIImage   *image  = [UIImage imageWithContentsOfFile:@"%@/%@.png",bundlePath,str];
//
//
//    NSString *str =[NSString stringWithFormat:@"JVerificationResource.bundle/%@",nameStr];
//
//
//    UIImage   *image =  [UIImage  imageNamed:str];
//
//
//    return  image;
//
//
//
//}
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//// 查询是否一键登录
//- (void)chaxunshipingyijiandenglu {
//
//
//
//
//
//        NSDictionary *parametes = @{
//                                   @"ct" :  @"app",
//                                    @"ios" : @"1",
//                                   @"ac" : @"config"
//
//                                   };
//       [HWWebUtils doGetWithParameters:parametes progress:nil success:^(id response) {
//
//
//
//
//
//
//               NSString *codeStr =  [NSString stringWithFormat:@"%@",response[@"code"]];
//                if ([codeStr intValue] == 1) {
//
//                    NSString   *onelogin  = [NSString stringWithFormat:@"%@",response[@"data"][@"onelogin"]];
//
//                    if ([onelogin intValue] == 1) {
//
//                                 dispatch_async(dispatch_get_main_queue(), ^{
//                                      [self quickLoginBtnClick];
//                                });
//
//                    }
//
//
//
//                }
//
//                NSLog(@"%@",response);
//
//
//
//       } failure:^(NSString *error) {
//           [SVProgressHUD dismiss];
//
//
//       }];
//
//
//
//
//
//
//
//
//
//
//
//
//
//}
//
//
//
//
//
//
//- (void)shanYanAuthPageLogin{
//    NSLog(@"DKJKDK");
//   //  [self quickLoginBtnClick:nil]；
//}
//
//
//
//- (void)quickLoginBtnClick {
//
//
//
//    BOOL isSetupClient = [JVERIFICATIONService isSetupClient];
//    if (isSetupClient) {
//      //初始化完成，可以进行后续操作
//        NSLog(@"ooooo");
//      //   [self huqouToken];
//
//
//    }
//
//     [self huqouToken];
//
//
//
//}
//
//
//- (void)huqouToken {
//
//
////     JVUIConfig *config = [[JVUIConfig alloc] init];
////     config.navReturnImg = [UIImage imageNamed:@"fanhui"];
////     config.autoLayout = YES;
////
////
////
////    //登录按钮
//////       UIImage *login_nor_image = [self imageNamed:@"loginBtn_Nor"];
//////       UIImage *login_dis_image = [self imageNamed:@"loginBtn_Dis"];
//////       UIImage *login_hig_image = [self imageNamed:@"loginBtn_Hig"];
////    UIImage *login_nor_image =  [UIImage imageNamed:@"xuanzhongbienin"];
////    UIImage *login_dis_image =  [UIImage imageNamed:@"xuanzhongbienin"];
////    UIImage *login_hig_image =  [UIImage imageNamed:@"xuanzhongbienin"];
////
////
////
////
////   //  personal_b
////       if (login_nor_image && login_dis_image && login_hig_image) {
////           config.logBtnImgs = @[login_nor_image, login_dis_image, login_hig_image];
////       }
//////       CGFloat loginButtonWidth = login_nor_image.size.width?:100;
//////       CGFloat loginButtonHeight = login_nor_image.size.height?:100;
////
////
////    CGFloat loginButtonWidth = 200;
////    CGFloat loginButtonHeight = 40;
////
////
////       JVLayoutConstraint *loginConstraintX = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterX multiplier:1 constant:0];
////       JVLayoutConstraint *loginConstraintY = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterY multiplier:1 constant:30];
////       JVLayoutConstraint *loginConstraintW = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeWidth multiplier:1 constant:loginButtonWidth];
////       JVLayoutConstraint *loginConstraintH = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeHeight multiplier:1 constant:loginButtonHeight];
////       config.logBtnConstraints = @[loginConstraintX,loginConstraintY,loginConstraintW,loginConstraintH];
////       config.logBtnHorizontalConstraints = config.logBtnConstraints;
////
////
////
////
////
//////    UIImage * uncheckedImg = [self imageNamed:@"checkBox_unSelected"];
//////       UIImage * checkedImg = [self imageNamed:@"checkBox_selected"];
//////
////    UIImage * uncheckedImg = [UIImage imageNamed:@"weixuanzhon"];
////       UIImage * checkedImg = [UIImage imageNamed:@"xuanzhong"];
////
////
////       CGFloat checkViewWidth = uncheckedImg.size.width;
////       CGFloat checkViewHeight = uncheckedImg.size.height;
////       config.uncheckedImg = uncheckedImg;
////       config.checkedImg = checkedImg;
////       JVLayoutConstraint *checkViewConstraintX = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeLeft multiplier:1 constant:20];
////       JVLayoutConstraint *checkViewConstraintY = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemPrivacy attribute:NSLayoutAttributeCenterY multiplier:1 constant:0];
////       JVLayoutConstraint *checkViewConstraintW = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeWidth multiplier:1 constant:checkViewWidth];
////       JVLayoutConstraint *checkViewConstraintH = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeHeight multiplier:1 constant:checkViewHeight];
////       config.checkViewConstraints = @[checkViewConstraintX,checkViewConstraintY,checkViewConstraintW,checkViewConstraintH];
////       config.checkViewHorizontalConstraints = config.checkViewConstraints;
////
////
////       //隐私
////       CGFloat spacing = checkViewWidth + 20 + 5;
////       config.privacyState = YES;
////
////       JVLayoutConstraint *privacyConstraintX = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeLeft multiplier:1 constant:spacing];
////       JVLayoutConstraint *privacyConstraintX2 = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeRight multiplier:1 constant:-spacing];
////       JVLayoutConstraint *privacyConstraintY = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeBottom multiplier:1 constant:-10];
////       JVLayoutConstraint *privacyConstraintH = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeHeight multiplier:1 constant:50];
////       config.privacyConstraints = @[privacyConstraintX,privacyConstraintX2,privacyConstraintY,privacyConstraintH];
////       config.privacyHorizontalConstraints = config.privacyConstraints;
////
////
////       //loading
////       JVLayoutConstraint *loadingConstraintX = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterX multiplier:1 constant:0];
////       JVLayoutConstraint *loadingConstraintY = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterY multiplier:1 constant:0];
////       JVLayoutConstraint *loadingConstraintW = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeWidth multiplier:1 constant:30];
////       JVLayoutConstraint *loadingConstraintH = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeHeight multiplier:1 constant:30];
////       config.loadingConstraints = @[loadingConstraintX,loadingConstraintY,loadingConstraintW,loadingConstraintH];
////       config.loadingHorizontalConstraints = config.loadingConstraints;
////
////
////       /*
////       config.authPageBackgroundImage = [UIImage imageNamed:@"背景图"];
////       config.navColor = [UIColor redColor];
////       config.preferredStatusBarStyle = 0;
////       config.navText = [[NSAttributedString alloc] initWithString:@"自定义标题"];
////       config.navReturnImg = [UIImage imageNamed:@"自定义返回键"];
////       UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
////       button.frame = CGRectMake(0, 0, 44, 44);
////       button.backgroundColor = [UIColor greenColor];
////       config.navControl = [[UIBarButtonItem alloc] initWithCustomView:button];
////       config.logoHidden = NO;
////       config.logBtnText = @"自定义登录按钮文字";
////       config.logBtnTextColor = [UIColor redColor];
////       config.numberColor = [UIColor blueColor];
////       config.appPrivacyOne = @[@"应用自定义服务条款1",@"https://www.jiguang.cn/about"];
////       config.appPrivacyTwo = @[@"应用自定义服务条款2",@"https://www.jiguang.cn/about"];
////       config.privacyComponents = @[@"文本1",@"文本2",@"文本3",@"文本4"];
////       config.appPrivacyColor = @[[UIColor redColor], [UIColor blueColor]];
////       config.sloganTextColor = [UIColor redColor];
////       config.navCustom = NO;
////       config.numberSize = 24;
////       config.privacyState = YES;
////        */
//////       [JVERIFICATIONService customUIWithConfig:config customViews:^(UIView *customAreaView) {
//////           /*
//////           //添加一个自定义label
//////           UILabel *lable  = [[UILabel alloc] init];
//////           lable.text = @"这是一个自定义label";
//////           [lable sizeToFit];
//////           lable.center = customAreaView.center;
//////           [customAreaView addSubview:lable];
//////            */
//////
//////       }];
//////
////
////
////
////
////
////   //   JVUIConfig *config1 = [[JVUIConfig alloc] init];
////
////
////
////
////    [JVERIFICATIONService customUIWithConfig:config];
////
////
////
////
//////
//////       config.customLoadingViewBlock = ^(UIView *View) {
//////             MBProgressHUD *hub = [MBProgressHUD showHUDAddedTo:View animated:YES];
//////                    hub.backgroundColor = [UIColor clearColor];
//////                    hub.label.text = @"正在登录..";
//////                    [hub showAnimated:YES];
//////
//////
//////
//////
//////
//////       };
//
//
//
//
//
//    [JVERIFICATIONService getAuthorizationWithController:self hide:YES animated:YES timeout:5*1000 completion:^(NSDictionary *result) {
//        NSLog(@"一键登录 result:%@", result);
//
//        NSString *code =  [NSString stringWithFormat:@"%@",result[@"code"]];
//
//        if ([code intValue] == 6000) {
//               [self  oneClickToLogIn:result[@"loginToken"]];
//        }
//
//
//
//
//
//
//
//
//
//    } actionBlock:^(NSInteger type, NSString *content) {
//        NSLog(@"一键登录 actionBlock :%ld %@", (long)type , content);
//    }];
//
//
//
//
//
////             [JVERIFICATIONService getToken:5*1000  completion:^(NSDictionary *result) {
////                           NSLog(@"11 getToken result:%@", result);
////
////                           [self  oneClickToLogIn:result[@"oneClickToLogIn"]];
////
////
////
////                              //TODO:获取token后相关操作
////                       }];
//
//
//
////    [JVERIFICATIONService getAuthorizationWithController:self hide:YES completion:^(NSDictionary *result) {
////        NSLog(@"一键登录 result:%@", result);
////    }];
//}
//
//
//
//
//
//// 手机号一键登录
//- (void)oneClickToLogIn: (NSString *)tokenStr {
//
//
//
//
//      NSString *tStr = [NSString stringWithFormat:@"%ld",[WMUtil getTimeSp]];
//
//
//      NSString *signStr = [NSString stringWithFormat:@"%@%@%@",tokenStr,tStr,@"riowreopfdwrops21qe"];
//      NSString  *signStrMd5  =   [WMUtil md5HexDigest:signStr];
//       DLog(@"MD5 ：%@",signStrMd5);
//
//
//
//    NSDictionary *parametes = @{
//                                      @"ios" : @"1",
//                                      @"token":tokenStr,
//                                      @"ct"  : @"app",
//                                      @"ac" : @"mobile_login",
//                                      @"t" :tStr,
//                                      @"sign" : signStrMd5,
//                                     };
//
//
//       [MBProgressHUD showMessage:@"正在登录"];
//
//         [HWWebUtils doGetWithParameters:parametes progress:nil success:^(id response) {
//
//
//
//             NSString *codeStr =  [NSString stringWithFormat:@"%@",response[@"code"]];
//             if ([codeStr intValue] == 1) {
//
//                   NSLog(@"jjjj %@",response);
//                   [MBProgressHUD showSuccess:@"登录成功"];
//
//                   [HWLocallyStoredData setUserID:response[@"data"]];
//
//
//                 if ([self.jizhuStr isEqualToString:@"1"]) {
//                  //     [HWLocallyStoredData setAccount:user_nameStr];
//
//
//
//                 }
//
//                [self.navigationController popViewControllerAnimated:YES];
//
//
//
//
//             } else {
//
//               [MBProgressHUD showError:response[@"message"]];
//
//
//
//             }
//
//
//
//         } failure:^(NSString *error) {
//            // [SVProgressHUD dismiss];
//
//              [MBProgressHUD showSuccess:@"登录失败"];
//             [MBProgressHUD hideHUD];
//
//
//         }];
//
//
//
//
//
//
//
//
//}
//
//
//
//
//
//
//
//
//
//
//- (void)setupUI {
//
//    self.view.backgroundColor = [UIColor whiteColor];
//
//
//    UIImageView *beijiimageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, 254*CFLScaleValue+StatusBarHeight)];
//    beijiimageView.image = [UIImage imageNamed:@"login_sign_bg"];
//    beijiimageView.userInteractionEnabled = YES;
//    beijiimageView.hidden = YES;
//    [self.view addSubview:beijiimageView];
//
//
//
//    [self addLogview];
//
//}
//
//-(void)addLogview {
//
//    self.loginView = [[UIView alloc]initWithFrame:CGRectMake(25, 68+NavBarHeight, kScreenW-50, 215)];
//   // self.loginView.frame = CGRectMake(50,68+NavBarHeight, kScreenW-100, 70+65+12+65);
//    self.loginView.backgroundColor = [UIColor redColor];
//
//   //  self.loginView.backgroundColor = [UIColor whiteColor];
////    self.loginView.layer.shadowColor = [UIColor colorWithRed:26/255.0 green:113/255.0 blue:255/255.0 alpha:0.35].CGColor;
////    self.loginView.layer.shadowOffset = CGSizeMake(0,0);
////    self.loginView.layer.shadowOpacity = 1;
////    self.loginView.layer.shadowRadius = 10;
////    self.loginView.layer.cornerRadius = 6;
////    self.loginView.layer.masksToBounds = YES;
////    self.loginView.clipsToBounds = NO;
//    [self.view addSubview:self.loginView];
//
//
//
//
//
//
//
//    UITextField *textfeild = [[UITextField alloc]initWithFrame:CGRectMake(15, 91,self.loginView.width-30 , 35)];
//    textfeild.placeholder = @"请输入账号";
//    textfeild.textColor = RGB(51, 51, 51);
//    textfeild.font = [UIFont systemFontOfSize:13];
//    textfeild.borderStyle =UITextBorderStyleNone;
//    textfeild.layer.borderWidth = 1;
//    textfeild.layer.borderColor = RGB(230, 239, 233).CGColor;
//    textfeild.layer.cornerRadius = 6;
//    textfeild.layer.masksToBounds = YES;
//    UIView *youbinview = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 19+16, 35)];
//    textfeild.leftView = youbinview;
//    UIImageView *imgeView = [[UIImageView alloc]initWithFrame:CGRectMake(11, 9, 16, 16)];
//    imgeView.image = [UIImage imageNamed:@"sign_phone"];
//    [youbinview addSubview:imgeView];
//    self.accounttextField = textfeild;
//    textfeild.leftViewMode = UITextFieldViewModeAlways;
//    if ([[HWLocallyStoredData getAccount] isEqualToString:@""]) {
//        textfeild.text = @"";
//
//    } else {
//
//        textfeild.text = [HWLocallyStoredData getAccount];
//
//    }
//
//    [self.loginView addSubview:textfeild];
//
//
//    UITextField *textfeild1 = [[UITextField alloc]initWithFrame:CGRectMake(15, 91+35+12,self.loginView.width-30 , 35)];
//    textfeild1.placeholder = @"请输入密码";
//    textfeild1.secureTextEntry = YES;
//    textfeild1.textColor = RGB(51, 51, 51);
//    textfeild1.font = [UIFont systemFontOfSize:13];
//    textfeild1.borderStyle =UITextBorderStyleNone;
//    textfeild1.layer.borderWidth = 1;
//    textfeild1.layer.borderColor = RGB(230, 239, 233).CGColor;
//    textfeild1.layer.cornerRadius = 6;
//    textfeild1.layer.masksToBounds = YES;
//    UIView *youbinview1 = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 19+16, 35)];
//    UIImageView *imgeView1 = [[UIImageView alloc]initWithFrame:CGRectMake(11, 9, 16, 16)];
//    imgeView1.image = [UIImage imageNamed:@"sign_password"];
//
//    textfeild1.leftView = youbinview1;
//
//    [youbinview1 addSubview:imgeView1];
//    textfeild1.leftViewMode = UITextFieldViewModeAlways;
//
//    UIView *righview4 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 30, 35)];
//    textfeild1.rightView = righview4;
//    textfeild1.rightViewMode = UITextFieldViewModeAlways;
//
////    UIImageView *imgeView4 = [[UIImageView alloc]initWithFrame:CGRectMake(0, 9, 16, 16)];
////    imgeView4.image = [UIImage imageNamed:@"sign_surep"];
////    [righview4 addSubview:imgeView4];
//    self.miaTexfeild = textfeild1;
//
//    UIButton *xianshyanj = [UIButton buttonWithType:UIButtonTypeCustom];
//    xianshyanj.frame = CGRectMake(0,9, 16, 16);
//    [xianshyanj setBackgroundImage:[UIImage imageNamed:@"sign_surep"] forState:UIControlStateNormal];
//     [xianshyanj setBackgroundImage:[UIImage imageNamed:@"kaijisign_surep_b"] forState:UIControlStateSelected];
//    [righview4 addSubview:xianshyanj];
//
//    [xianshyanj addTarget:self action:@selector(xianshyanjTap:) forControlEvents:UIControlEventTouchUpInside];
//
//    [self.loginView addSubview:textfeild1];
//
//
//
//    UIButton *wangjibutton = [UIButton buttonWithType:UIButtonTypeCustom];
//    wangjibutton.frame = CGRectMake(self.loginView.width-62-18,self.loginView.height-42+6, 62, 30);
//    [wangjibutton setTitle:@"忘记密码？" forState:UIControlStateNormal];
//    [wangjibutton setTitleColor:RGB(26, 113, 255) forState:UIControlStateNormal];
//    wangjibutton.titleLabel.font = [UIFont systemFontOfSize:12];
//    [wangjibutton addTarget:self action:@selector(wangjibuttonTap) forControlEvents:UIControlEventTouchUpInside];
//
//   // wangjibutton.backgroundColor = [UIColor redColor];
//    [self.loginView addSubview:wangjibutton];
//
//
//
//    UIButton *jizhubutt  = [UIButton setButtonWithFrame:CGRectMake(17, self.loginView.height-42+6, 64, 30) Title:@"记住账号" Image:@"weixuanzhon_bynenn" Font:12 Color:RGB(153, 153, 153) Target:self Selector:@selector(buttonTap:)];
//    [jizhubutt setImage:[UIImage imageNamed:@"sign_sure"] forState:UIControlStateSelected];
//    self.jizhuStr = @"0";
//    [jizhubutt layoutButtonWithEdgeInsetsStyle:MKButtonEdgeInsetsStyleLeft imageTitleSpace:4];
//
//    [self.loginView addSubview:jizhubutt];
//
//
//
//    self.icoImageView = [[UIImageView alloc]initWithFrame:CGRectMake((self.loginView.width-85)/2, -85/2, 85, 85)];
//    self.icoImageView.image = [UIImage imageNamed:@"acat"];
//    self.icoImageView.layer.cornerRadius = 85/2;
//    self.icoImageView.layer.masksToBounds = YES;
//    self.icoImageView.layer.borderWidth = 5;
//    self.icoImageView.layer.borderColor  =  RGB(255, 255, 255).CGColor;
//    [self.loginView addSubview: self.icoImageView];
//
//
//
//
//  //  self.loginView.bottom+21
//    UIButton *loginbutt  = [UIButton setButtonWithFrame:CGRectMake(25,self.loginView.bottom+21,kScreenW-50, 44) Title:@"登录" Image:nil Font:15 Color:RGB(255, 255, 255) Target:self Selector:@selector(logtapTap:)];
//  //  loginbutt.backgroundColor = RGB(68, 94, 233);
//  //  [loginbutt setBackgroundImage:[UIImage imageNamed:@"button_s"] forState:UIControlStateNormal];
//    loginbutt.layer.shadowColor = [UIColor colorWithRed:26/255.0 green:113/255.0 blue:255/255.0 alpha:0.35].CGColor;
//    loginbutt.layer.shadowOffset = CGSizeMake(0,0);
//    loginbutt.layer.shadowOpacity = 1;
//    loginbutt.layer.shadowRadius = 10;
//    loginbutt.layer.cornerRadius = 6;
//    loginbutt.layer.masksToBounds = YES;
//    loginbutt.clipsToBounds = NO;
//    [self.view addSubview:loginbutt];
//
//    loginbutt.backgroundColor = QCchunseshensetupian;
//
//
//
//
//
//
//
//
//    UIView  *zhuceview  = [[UIView alloc]initWithFrame:CGRectMake((kScreenW -60-60-70)/2, 5+loginbutt.bottom, 60+60+70, 40)];
//
//   // zhuceview.backgroundColor = [UIColor redColor];
//    [self.view addSubview:zhuceview];
//    NSArray *arr =  @[@"账号注册",@"手机号注册",@" 游客登录"];
//    for (int i = 0; i < 3 ; i++) {
//         UIButton *zhucebutt  = [UIButton setButtonWithFrame:CGRectMake(0,0,kScreenW-50, 40) Title:arr[i] Image:nil Font:13 Color:RGB(153, 153, 153) Target:self Selector:@selector(zhucebutttap:)];
//        zhucebutt.tag = i;
//
//        if (i == 0) {
//            zhucebutt.frame = CGRectMake(0, 0, 60, 40);
//        } else if (i == 1) {
//
//            zhucebutt.frame = CGRectMake(60, 0, 70, 40);
//        } else {
//
//            zhucebutt.frame = CGRectMake(60+70, 0, 60, 40);
//        }
//        [zhuceview addSubview:zhucebutt];
//
//
//    }
//
//
//
//    for (int i = 0 ; i < 2; i++) {
//        UIView  *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 1, 13)];
//        view.backgroundColor = RGB(153, 153, 153);
//        [zhuceview addSubview:view];
//
//        if (i == 0) {
//
//
//            view.frame = CGRectMake(59, 13, 1, 13);
//
//        } else {
//
//            view.frame = CGRectMake(59+70, 13, 1, 13);
//        }
//
//
//    }
//
//
//
//
//
//      UIButton *weixingBut = [UIButton buttonWithType:UIButtonTypeCustom];
//       weixingBut.frame = CGRectMake((self.view.frame.size.width-130)/2,self.view.height-70, 50, 50);
//      // [weixingBut setTitle:@"忘记密码？" forState:UIControlStateNormal];
//     //  [weixingBut setTitleColor:RGB(26, 113, 255) forState:UIControlStateNormal];
//       weixingBut.titleLabel.font = [UIFont systemFontOfSize:12];
//       [weixingBut addTarget:self action:@selector(weixingButtap:) forControlEvents:UIControlEventTouchUpInside];
//       self.weixingBut = weixingBut;
//      // wangjibutton.backgroundColor = [UIColor redColor];
//      //  self.weixingBut.backgroundColor = [UIColor redColor];
//       weixingBut.layer.cornerRadius = 25;
//       weixingBut.layer.masksToBounds = YES;
//       [weixingBut setBackgroundImage:[UIImage imageNamed:@"weixin"] forState:UIControlStateNormal];
//       [self.view  addSubview:weixingBut];
//
//
//
//
//      UIButton *QQBut = [UIButton buttonWithType:UIButtonTypeCustom];
//        QQBut.frame = CGRectMake((self.view.frame.size.width-130)/2+80,self.view.height-70, 50, 50);
//         // [weixingBut setTitle:@"忘记密码？" forState:UIControlStateNormal];
//        //  [weixingBut setTitleColor:RGB(26, 113, 255) forState:UIControlStateNormal];
//          QQBut.titleLabel.font = [UIFont systemFontOfSize:12];
//          [QQBut addTarget:self action:@selector(QQButtap:) forControlEvents:UIControlEventTouchUpInside];
//          self.QQBut = QQBut;
//         // wangjibutton.backgroundColor = [UIColor redColor];
//         //  self.weixingBut.backgroundColor = [UIColor redColor];
//          QQBut.layer.cornerRadius = 25;
//          QQBut.layer.masksToBounds = YES;
//          [QQBut setBackgroundImage:[UIImage imageNamed:@"qq"] forState:UIControlStateNormal];
//          [self.view  addSubview:QQBut];
//
//         //  这两个暂时隐藏了
//         self.weixingBut.hidden = YES;
//         self.QQBut.hidden = YES;
//
//
//
//
//
//
//
//
//
//
//}
//
//
//- (void)navigaView  {
//
//    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
//    button.frame = CGRectMake(10,StatusBarHeight, 40, 44);
//    // button.backgroundColor = [UIColor redColor];
//    [button setImage:[UIImage imageNamed:@"fanyudetails_back"] forState:UIControlStateNormal];
//    [button addTarget:self action:@selector(buttonTap) forControlEvents:UIControlEventTouchUpInside];
//    [self.view addSubview:button];
//
//    UILabel *textlabel = [[UILabel alloc]initWithFrame:CGRectMake((kScreenW-70)/2, StatusBarHeight, 70, 44)];
//    textlabel.text = @"登录";
//    textlabel.textAlignment =  NSTextAlignmentCenter;
//    textlabel.textColor = [UIColor whiteColor];
//    textlabel.font = [UIFont systemFontOfSize:16];
//    [self.view addSubview:textlabel];
//
//
//
//
//
//
//
//
//
//}
//
//
//
//
////
//- (void)buttonTap {
//
//
//    [self.navigationController setNavigationBarHidden:NO animated:YES];
//    [self.navigationController popViewControllerAnimated:YES];
//
//}
//
//
//#pragma  mark -------- 一些点击事件
//
////记住账号
//- (void)buttonTap:(UIButton *)sender {
//
//    if (sender.selected == YES) {
//
//        sender.selected = NO;
//         self.jizhuStr  = @"0";
//
//
//    } else {
//
//        sender.selected = YES;
//        self.jizhuStr  = @"1";
//
//
//    }
//
//
//
//}
//
//
//// 点击登录按钮
//- (void)logtapTap:(UIButton *)sender {
//
//
//    if(!(self.accounttextField.text.length > 0)) {
//
//        [MBProgressHUD showError:@"请输入账号"];
//        return;
//    } else if (!(self.miaTexfeild.text.length > 0)) {
//
//        [MBProgressHUD showError:@"请输入密码"];
//        return;
//
//    }
//
//    DLog(@"登录按钮");
//
//    NSString *user_nameStr = self.accounttextField.text;
//    NSString *passwdStr = self.miaTexfeild.text;
//
//    NSString *tStr = [NSString stringWithFormat:@"%ld",[WMUtil getTimeSp]];
//
//
//    NSString *signStr = [NSString stringWithFormat:@"%@%@%ld%@",user_nameStr,passwdStr,[WMUtil getTimeSp],@"riowreopfdwrops21qe"];
//    NSString  *signStrMd5  =   [WMUtil md5HexDigest:signStr];
//     DLog(@"MD5 ：%@",signStrMd5);
//
//
//
//    NSDictionary *parametes = @{
//                                      @"ios" : @"1",
//                                      @"user_name":user_nameStr,
//                                      @"ct"  : @"app",
//                                      @"ac" : @"login",
//                                      @"passwd" :passwdStr,
//                                      @"t" : tStr,
//                                      @"sign" :signStrMd5
//
//                                     };
//
//
//
//
//         [HWWebUtils doGetWithParameters:parametes progress:nil success:^(id response) {
//
//
//
//             NSString *codeStr =  [NSString stringWithFormat:@"%@",response[@"code"]];
//             if ([codeStr intValue] == 1) {
//
//                   NSLog(@"%@",response);
//                   [MBProgressHUD showSuccess:@"登录成功"];
//
//                   [HWLocallyStoredData setUserID:response[@"data"]];
//
//
//                 if ([self.jizhuStr isEqualToString:@"1"]) {
//                      [HWLocallyStoredData setAccount:user_nameStr];
//
//                 }
//
//                [self.navigationController popViewControllerAnimated:YES];
//
//
//
//
//             } else {
//
//               [MBProgressHUD showError:response[@"message"]];
//
//
//
//             }
//
//
//
//         } failure:^(NSString *error) {
//            // [SVProgressHUD dismiss];
//
//              [MBProgressHUD showSuccess:@"登录失败"];
//             [MBProgressHUD hideHUD];
//
//
//         }];
//
//
//
//
//
//
//
//}
//
//
//
//
//// 是否是明文
//- (void)xianshyanjTap:(UIButton *)sende {
//
//    if (sende.selected == YES) {
//
//        sende.selected = NO;
//        // 密码
//         self.miaTexfeild.secureTextEntry = YES;
//    } else {
//
//         sende.selected = YES;
//         // 明文
//
//         self.miaTexfeild.secureTextEntry = NO;
//    }
//
//}
//
//
//- (void)zhucebutttap:(UIButton *)sender {
//
//    if (sender.tag == 0) {
//
//        HWAccountRegisteredViewController *accountRegiste =[[HWAccountRegisteredViewController alloc]init];
//        [self.navigationController pushViewController:accountRegiste animated:YES];
//
//    } else  if(sender.tag == 1){
//
//        HWPhoneRegisteredController *phoen = [[HWPhoneRegisteredController alloc]init];
//        [self.navigationController pushViewController:phoen animated:YES];
//
//    } else {
//
//
//
//         NSString *tStr = [NSString stringWithFormat:@"%ld",[WMUtil getTimeSp]];
//         NSString *sign = [NSString stringWithFormat:@"%@%@",tStr,@"fsd213ewdsadqwe2121213edsad"];
//
//         NSString  *signStrMd5  =   [WMUtil md5HexDigest:sign];
//
//         NSString *bundlePath = [[NSBundle mainBundle] bundlePath];
//
//                   NSString *path2 = [NSString stringWithFormat:@"%@/%@", bundlePath, @"coid"];
//
//                   NSFileManager *manager = [NSFileManager defaultManager];
//
//           //        NSString *channel = @"";
//
//
//                  NSString *channel = [NSString string];
//                   if ([manager fileExistsAtPath:path2]) {
//                       NSArray *allPath =[manager subpathsAtPath:path2];
//                       //4.遍历所有的子路径
//                       for (NSString *subPath in allPath) {
//                           if ([subPath containsString:@"coid_"]) {
//                               channel = [subPath substringFromIndex:@"coid_".length];
//                               NSLog(@"文件夹名字%@+++",  channel);
//                           }
//                       }
//                   }
//                   if ([channel isEqual:@""]) {
//                       member_id = [NSString stringWithFormat:@"0"];
//                   } else {
//                       member_id = [NSString stringWithFormat:@"%@",channel];
//                   }
//                   NSLog(@"有值吗++%@+++", member_id);
//
//
//         NSDictionary *parametes = @{
//                                         @"ct" : @"app",
//                                         @"ac" : @"shiwan",
//                                         @"ios" : @"1",
//                                         @"t" : tStr,
//                                         @"str": [self randomStringWithLength:10],
//                                         @"sign":signStrMd5,
//                                         @"member_id":member_id
//
//                                        };
//
//            [HWWebUtils doGetWithParameters:parametes progress:nil success:^(id response) {
//
//
//                NSString *codeStr =  [NSString stringWithFormat:@"%@",response[@"code"]];
//                if ([codeStr intValue] == 1) {
//                  //  [SVProgressHUD showSuccessWithStatus:@"发送成功"];
//
//
//
//
//                   // [MBProgressHUD showSuccess:@"游客登录成功"];
//
//
//
//                     self.touristsView = [[HWTouristsView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, kScreenH)];
//                    self.touristsView.delegate = self;
//                    self.touristsView.dataDic = response[@"data"];
//                    [HWLocallyStoredData setUserID:response[@"data"][@"uid"]];
//
//                    [kKeyWindow addSubview:self.touristsView];
//
//
//
//
//
//                    NSLog(@"%@",response);
//
//
//                } else {
//
//                 //    [SVProgressHUD showInfoWithStatus:response[@"message"]];
//                    [MBProgressHUD showError:response[@"message"]];
//
//                 NSLog(@"%@",response);
//
//                }
//
//              //  [SVProgressHUD dismiss];
//
//              // [MBProgressHUD hideHUD];
//
//
//            } failure:^(NSString *error) {
//               // [SVProgressHUD dismiss];
//                [MBProgressHUD hideHUD];
//
//
//            }];
//
//
//
//
//
//
////        self.touristsView = [[HWTouristsView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, kScreenH)];
////        [kKeyWindow addSubview:self.touristsView];
//
//    }
//
//
//}
//
//
//-(NSString *)randomStringWithLength:(NSInteger)len {
//     NSString *letters = @"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
//    NSMutableString *randomString = [NSMutableString stringWithCapacity: len];
//
//    for (NSInteger i = 0; i < len; i++) {
//        [randomString appendFormat: @"%C", [letters characterAtIndex: arc4random_uniform([letters length])]];
//    }
//    return randomString;
//
//
//
//}
//
//
//
//#pragma mark ---- 点击
//-(void)jizhu {
//    [self.navigationController popViewControllerAnimated:YES];
//
//}
//
////#pragma  mark -----  iOS AES128加解密
//////加密
////+(NSString *)AES128Encrypt:(NSString *)plainText key:(NSString *)key
////{
////    char keyPtr[kCCKeySizeAES128+1];
////    memset(keyPtr, 0, sizeof(keyPtr));
////    [key getCString:keyPtr maxLength:sizeof(keyPtr) encoding:NSUTF8StringEncoding];
////
////    NSData* data = [plainText dataUsingEncoding:NSUTF8StringEncoding];
////    NSUInteger dataLength = [data length];
////
////    size_t bufferSize = dataLength + kCCBlockSizeAES128;
////    void *buffer = malloc(bufferSize);
////    size_t numBytesEncrypted = 0;
////    CCCryptorStatus cryptStatus = CCCrypt(kCCEncrypt,
////                                          kCCAlgorithmAES128,
////                                          kCCOptionPKCS7Padding|kCCOptionECBMode,
////                                          keyPtr,
////                                          kCCBlockSizeAES128,
////                                          NULL,
////                                          [data bytes],
////                                          dataLength,
////                                          buffer,
////                                          bufferSize,
////                                          &numBytesEncrypted);
////    if (cryptStatus == kCCSuccess) {
////        NSData *resultData = [NSData dataWithBytesNoCopy:buffer length:numBytesEncrypted];
////        //return [GTMBase64 stringByEncodingData:resultData];
////        return [self hexStringFromData:resultData];
////
////    }
////    free(buffer);
////    return nil;
////}
////
//
//
//#pragma mark --------- 忘记密码
//- (void)wangjibuttonTap {
//
//    NSLog(@"忘记密码");
////    HWVerificationViewController  *verifica = [[HWVerificationViewController alloc]init];
////    [self.navigationController pushViewController:verifica animated:YES];
////
////
//    HWForgotPasswordViewController *forgotPassword = [[HWForgotPasswordViewController alloc]init];
//    [self.navigationController pushViewController:forgotPassword animated:YES];
//
//
//
//
//}
//
//
//
//
//- (void)weixingButtap:(UIButton *)sender {
//
//    [self login];
//
//
//
//
//
//}
//
//
//
//
//
//
//
//- (void)QQButtap:(UIButton *)sender {
//
//    NSLog(@"QQ");
//
//    [self QQlogin];
//
//
//
//
//}
//
//
//// 微信
//- (void)login{
//    //判断微信是否安装
//    if([WXApi isWXAppInstalled]){
//        SendAuthReq *req = [[SendAuthReq alloc] init];
//        req.scope = @"snsapi_userinfo";
//        req.state = @"App";
//        [WXApi sendAuthReq:req viewController:self delegate:self];
//
//
//    }else{
//        [self setupAlertController];
//    }
//}
//
//- (void)setupAlertController{
//    UIAlertController *vc = [UIAlertController alertControllerWithTitle:@"温馨提示" message:@"请先安装微信客户端" preferredStyle:UIAlertControllerStyleAlert];
//    UIAlertAction *actionConfim = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:nil];
//    [vc addAction:actionConfim];
//    [self presentViewController:vc animated:YES completion:nil];
//}
//
//- (void)wxLogin:(NSNotification*)noti{
//    //获取到code
//    SendAuthResp *resp = noti.object;
//    NSLog(@"%@",resp.code);
//    _code = resp.code;
//
//    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
//    NSString *url = [NSString stringWithFormat:@"https://api.weixin.qq.com/sns/oauth2/access_token?appid=%@&secret=%@&code=%@&grant_type=%@",weixiappId,appSecret,_code,@"authorization_code"];
//    manager.requestSerializer = [AFJSONRequestSerializer serializer];
//    [manager.requestSerializer setValue:@"text/html; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
//
//    NSMutableSet *mgrSet = [NSMutableSet set];
//    mgrSet.set = manager.responseSerializer.acceptableContentTypes;
//    [mgrSet addObject:@"text/html"];
//    //因为微信返回的参数是text/plain 必须加上 会进入fail方法
//    [mgrSet addObject:@"text/plain"];
//    [mgrSet addObject:@"application/json"];
//    manager.responseSerializer.acceptableContentTypes = mgrSet;
//
//    [manager GET:url parameters:nil progress:^(NSProgress * _Nonnull downloadProgress) {
//
//    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
//        NSLog(@"success");
//        NSDictionary *resp = (NSDictionary*)responseObject;
//        NSString *openid = resp[@"openid"];
//        NSString *unionid = resp[@"unionid"];
//        NSString *accessToken = resp[@"access_token"];
//        NSString *refreshToken = resp[@"refresh_token"];
//        if(accessToken && ![accessToken isEqualToString:@""] && openid && ![openid isEqualToString:@""]){
//            [[NSUserDefaults standardUserDefaults] setObject:openid forKey:WX_OPEN_ID];
//            [[NSUserDefaults standardUserDefaults] setObject:accessToken forKey:WX_ACCESS_TOKEN];
//            [[NSUserDefaults standardUserDefaults] setObject:refreshToken forKey:WX_REFRESH_TOKEN];
//            [[NSUserDefaults standardUserDefaults] synchronize];
//        }
//        [self getUserInfo];
//
//
//    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
//    }];
//
//}
//
//- (void)authAccessToken{
//    //验证accessToken是否是成功
//    NSString *accessToken = [[NSUserDefaults standardUserDefaults] objectForKey:WX_ACCESS_TOKEN];
//    NSString *openid = [[NSUserDefaults standardUserDefaults] objectForKey:WX_OPEN_ID];
//    if(!accessToken || [accessToken isEqualToString:@""] || !openid || [openid isEqualToString:@""]){
//        //如果没登陆过，则登陆
//        [self login];
//    }else{
//        //否则验证access token 是否还有效
//        AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
//        NSString *url = [NSString stringWithFormat:@"https://api.weixin.qq.com/sns/auth?access_token=%@&openid=%@",accessToken,openid];
//
//        NSMutableSet *mgrSet = [NSMutableSet set];
//        mgrSet.set = manager.responseSerializer.acceptableContentTypes;
//        [mgrSet addObject:@"text/html"];
//        //因为微信返回的参数是text/plain 必须加上 会进入fail方法
//        [mgrSet addObject:@"text/plain"];
//        [mgrSet addObject:@"application/json"];
//        manager.responseSerializer.acceptableContentTypes = mgrSet;
//
//        [manager GET:url parameters:nil progress:^(NSProgress * _Nonnull downloadProgress) {
//
//        } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
//            NSLog(@"success");
//            NSDictionary *resp = (NSDictionary*)responseObject;
//            if([resp[@"errcode"] intValue] == 0){
//                //有效则直接获取信息
//                [self getUserInfo];
//            }else{
//                //否则使用refreshtoken来刷新accesstoken
//                [self refreshAccessToken];
//            }
//        } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
//            NSLog(@"fail");
//            NSLog(@"%@",task.response);
//        }];
//    }
//
//
//}
//
//- (IBAction)refreshAccessToken:(UIButton *)sender {
//
//    [self refreshAccessToken];
//
//}
//
//- (void)refreshAccessToken{
//    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
//    NSString *url = [NSString stringWithFormat:@"https://api.weixin.qq.com/sns/oauth2/refresh_token?appid=%@&refresh_token=%@&grant_type=%@",[[NSUserDefaults standardUserDefaults] objectForKey:WX_OPEN_ID],[[NSUserDefaults standardUserDefaults] objectForKey:WX_REFRESH_TOKEN],@"REFRESH_TOKEN"];
//
//    NSMutableSet *mgrSet = [NSMutableSet set];
//    mgrSet.set = manager.responseSerializer.acceptableContentTypes;
//    [mgrSet addObject:@"text/html"];
//    //因为微信返回的参数是text/plain 必须加上 会进入fail方法
//    [mgrSet addObject:@"text/plain"];
//    [mgrSet addObject:@"application/json"];
//    manager.responseSerializer.acceptableContentTypes = mgrSet;
//
//    [manager GET:url parameters:nil progress:^(NSProgress * _Nonnull downloadProgress) {
//
//    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
//        NSLog(@"success");
//        NSDictionary *resp = (NSDictionary*)responseObject;
//        NSString *openid = resp[@"openid"];
//        NSString *accessToken = resp[@"access_token"];
//        NSString *refreshToken = resp[@"refresh_token"];
//        if(refreshToken){
//            if(accessToken && ![accessToken isEqualToString:@""] && openid && ![openid isEqualToString:@""]){
//                [[NSUserDefaults standardUserDefaults] setObject:openid forKey:WX_OPEN_ID];
//                [[NSUserDefaults standardUserDefaults] setObject:accessToken forKey:WX_ACCESS_TOKEN];
//                [[NSUserDefaults standardUserDefaults] setObject:refreshToken forKey:WX_REFRESH_TOKEN];
//                [[NSUserDefaults standardUserDefaults] synchronize];
//            }
//        }else{
//            //如果refreshToken为空，说明refreshToken也过期了，需要重新登陆
//            [self login];
//        }
//
//    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
//        NSLog(@"fail");
//        NSLog(@"%@",task.response);
//    }];
//}
//
//- (IBAction)getUserInfo:(UIButton *)sender {
//    [self getUserInfo];
//}
//
//- (void)getUserInfo{
//    //获取个人信息
//    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
//    NSString *url = [NSString stringWithFormat:@"https://api.weixin.qq.com/sns/userinfo?access_token=%@&openid=%@",[[NSUserDefaults standardUserDefaults] objectForKey:WX_ACCESS_TOKEN],[[NSUserDefaults standardUserDefaults] objectForKey:WX_OPEN_ID]];
//
//    NSMutableSet *mgrSet = [NSMutableSet set];
//    mgrSet.set = manager.responseSerializer.acceptableContentTypes;
//    [mgrSet addObject:@"text/html"];
//    //因为微信返回的参数是text/plain 必须加上 会进入fail方法
//    [mgrSet addObject:@"text/plain"];
//    [mgrSet addObject:@"application/json"];
//    manager.responseSerializer.acceptableContentTypes = mgrSet;
//
//    [manager GET:url parameters:nil progress:^(NSProgress * _Nonnull downloadProgress) {
//
//    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
//        NSLog(@"success");
//
//        NSLog(@"%@",responseObject);
//        NSDictionary *resp = (NSDictionary*)responseObject;
////        self->_nicknameLabel.text = resp[@"nickname"];
////        self->_sexLabel.text = [resp[@"sex"] intValue] == 1 ? @"男" : @"女";
////        self->_addressLabel.text = [NSString stringWithFormat:@"%@%@%@",resp[@"country"],resp[@"province"],resp[@"city"]];
//        [self fasongwangluoqingqiu:resp];
//
//
//    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
//        NSLog(@"fail");
//        NSLog(@"%@",task.response);
//    }];
//}
//
//
//- (void)fasongwangluoqingqiu:(NSDictionary *)dic {
//
//
//
//             NSDictionary *parametes = @{
//                                         @"ct" : @"azwxlogin",
//                                         @"ios" : @"1",
//                                         @"type": @"2",
//                                         @"openid":dic[@"unionid"],
//
//                                        };
//
//            [HWWebUtils doGetWithParameters:parametes progress:nil success:^(id response) {
//
//
//                NSString *codeStr =  [NSString stringWithFormat:@"%@",response[@"code"]];
//                if ([codeStr intValue] == 1) {
//                  //  [SVProgressHUD showSuccessWithStatus:@"发送成功"];
//
//
//                      NSLog(@"%@",response);
//
//                   // [MBProgressHUD showSuccess:@"游客登录成功"];
//
//
//
//                    [MBProgressHUD showSuccess:response[@"message"]];
//
//                    [HWLocallyStoredData setUserID:response[@"data"]];
//
//
//
//                    [self.navigationController popViewControllerAnimated:YES];
//
//
//
//
//
//                    NSLog(@"%@",response);
//
//
//                } else {
//
//                 //    [SVProgressHUD showInfoWithStatus:response[@"message"]];
//                    [MBProgressHUD showError:response[@"message"]];
//
//                 NSLog(@"%@",response);
//
//                }
//
//              //  [SVProgressHUD dismiss];
//
//              // [MBProgressHUD hideHUD];
//
//
//            } failure:^(NSString *error) {
//               // [SVProgressHUD dismiss];
//                [MBProgressHUD hideHUD];
//
//
//            }];
//
//
//
//
//
//
//
//}
//
//
//
//
//
//
//
//- (void)QQlogin {
//
//    //  #define  QQAPPID @"101574270"
//
//    NSLog(@"QQ登录");
//
//    _tencentOAuth = [[TencentOAuth alloc]initWithAppId:QQAPPID andDelegate:self];
//
//    NSArray *permissions = [NSArray arrayWithObjects:kOPEN_PERMISSION_GET_INFO, kOPEN_PERMISSION_GET_USER_INFO, kOPEN_PERMISSION_GET_SIMPLE_USER_INFO, nil];
//    // 这里调起登录
//    [_tencentOAuth authorize:permissions];
//
//
//
//
//
//}
//
//
//- (void)tencentDidLogin
//{
//    if (_tencentOAuth.accessToken.length > 0) {
//        // 获取用户信息
//     //   [_tencentOAuth getUserInfo];
//
//        [self QQDengluToken:_tencentOAuth.accessToken];
//
//
//
//
//    } else {
//        NSLog(@"登录不成功 没有获取accesstoken");
//    }
//}
//
////非网络错误导致登录失败：
//- (void)tencentDidNotLogin:(BOOL)cancelled {
//    if (cancelled) {
//        NSLog(@"用户取消登录");
//    } else {
//        NSLog(@"登录失败");
//    }
//
//}
//
//
//- (void)getUserInfoResponse:(APIResponse *)response {
//
//    if (response && response.retCode == URLREQUEST_SUCCEED) {
//
//        NSDictionary *userInfo = [response jsonResponse];
//        NSString *nickName = userInfo[@"nickname"];
//
//        // 后续操作...
//
//
//    } else {
//        NSLog(@"QQ auth fail ,getUserInfoResponse:%d", response.detailRetCode);
//    }
//
//}
//
//
//
//
//- (void)QQDengluToken:(NSString *)accessToken {
//
//
//
//
//      NSDictionary *parametes = @{
//                                          @"ct" : @"azwxlogin",
//                                          @"ios" : @"1",
//                                          @"type": @"1",
//                                          @"openid":accessToken,
//
//                                         };
//
//             [HWWebUtils doGetWithParameters:parametes progress:nil success:^(id response) {
//
//
//                 NSString *codeStr =  [NSString stringWithFormat:@"%@",response[@"code"]];
//                 if ([codeStr intValue] == 1) {
//                   //  [SVProgressHUD showSuccessWithStatus:@"发送成功"];
//
//
//                       NSLog(@"%@",response);
//
//                    // [MBProgressHUD showSuccess:@"游客登录成功"];
//
//
//
//                     [MBProgressHUD showSuccess:response[@"message"]];
//
//                     [HWLocallyStoredData setUserID:response[@"data"]];
//
//
//
//                     [self.navigationController popViewControllerAnimated:YES];
//
//
//
//
//
//                     NSLog(@"%@",response);
//
//
//                 } else {
//
//                  //    [SVProgressHUD showInfoWithStatus:response[@"message"]];
//                     [MBProgressHUD showError:response[@"message"]];
//
//                  NSLog(@"%@",response);
//
//                 }
//
//               //  [SVProgressHUD dismiss];
//
//               // [MBProgressHUD hideHUD];
//
//
//             } failure:^(NSString *error) {
//                // [SVProgressHUD dismiss];
//                 [MBProgressHUD hideHUD];
//
//
//             }];
//
//
//
//
//
//
//}
//
//@end












